Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AutoSave Example - React #30

Open
wants to merge 2 commits into
base: v1.x/master
Choose a base branch
from

Conversation

miteshgoplani
Copy link

@miteshgoplani miteshgoplani commented Jul 2, 2020

This PR serves as an example of how to subscribe to an AutoSave Event by Zowe Desktop for a React Application

This example demonstrates how to save the parameters and AppId of React App:

1. Retrieve the sessionEvents from the resources props
this.sessionEvents = this.props.resources.sessionEvents;

2. Subscribe to autosaveEmitter

    this.autoSaveEvent = this.sessionEvents.autosaveEmitter.subscribe((saveThis: any)=> {
      if (saveThis) {
        saveThis({'appData':{'requestText':this.state.parameters,'targetAppId':this.state.appId}});
      }
    });

3. Receive saved data
In order to receive the data, use data.appData.requestText and data.appData.targetAppId as seen in handleLaunchOrMessageObject()

Note:

  1. It is necessary to unsubscribe to the AutoSave Event when the component unmounts
  2. You must add an autosave property to pluginDefinition "autosave": true

Signed-off-by: miteshgoplani [email protected]

@miteshgoplani miteshgoplani changed the title [WIP] Add AutoSave Example [WIP] Add AutoSave Example - React Jul 2, 2020
@miteshgoplani miteshgoplani changed the title [WIP] Add AutoSave Example - React Add AutoSave Example - React Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant