Skip to content

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 miteshgoplani@gmail.com

@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
Signed-off-by: Mitesh <miteshgoplani@gmail.com>
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