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 an Angular Application

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

1. Inject the Session Events token
@Inject(Angular2InjectionTokens.SESSION_EVENTS) private sessionEvents: Angular2PluginSessionEvents

2. Subscribe to autosaveEmitter

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

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 is destroyed
  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 - Angular Jul 2, 2020
@miteshgoplani miteshgoplani changed the title [WIP] Add AutoSave Example - Angular Add AutoSave Example - Angular 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