introduce onReady life-cycle

Summary: Flipper Sandy plugins didn't have an event to hook into that is run _after_ any state snapshot is loaded, which was needed by the graphQL plugin, as they do some post processing when a data snapshot is restored.

Reviewed By: passy

Differential Revision: D28189573

fbshipit-source-id: 4ef992f3fafc32787eab3bc235059f2c41396c80
This commit is contained in:
Michel Weststrate
2021-05-04 12:51:32 -07:00
committed by Facebook GitHub Bot
parent 616341f649
commit dd7a9f5195
5 changed files with 57 additions and 19 deletions

View File

@@ -192,6 +192,13 @@ export function plugin(client: PluginClient) {
}
```
### `onReady`
The `onReady` event is triggered immediately after a plugin has been initialized and any pending state was restored.
This event fires after `onImport` / the interpretation of any `persist` flags and indicates that the initialization process has finished.
This event does not signal that the plugin is loaded in the UI yet (see `onActivated`) and does fire before deeplinks (see `onDeeplink`) are handled.
If a plugin has complex initialization logic it is recommended to put it in the `onReady` hook, as an error in the onReady hook won't cause the plugin not to be loaded.
### Methods
#### `send`