update js-client api (migrate to TS)
Summary: JS/TS api: - migrate to TS - some refactoring (get rid of bridge, make client abstract) Implementation isn't full yet, things to be implemented: - let plugins connect on init command from Flipper - implement Responder Further plans: - make fully compatible with react-native api without breaking changes Reviewed By: mweststrate Differential Revision: D21839377 fbshipit-source-id: 9e9fe4ad01632f958b59eb255c703c6cbc5fafe2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f88d707dbb
commit
896a90aa26
34
flipper-js-client-sdk/README.md
Normal file
34
flipper-js-client-sdk/README.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# flipper-sdk-api
|
||||
|
||||
SDK to build Flipper clients for JS based apps
|
||||
|
||||
## Installation
|
||||
|
||||
`yarn add flipper-client-sdk`
|
||||
|
||||
## Usage
|
||||
|
||||
## Example
|
||||
|
||||
```TypeScript
|
||||
class SeaMammalPlugin extends AbsctractFlipperPlugin {
|
||||
getId(): string {
|
||||
return 'sea-mammals';
|
||||
}
|
||||
|
||||
runInBackground(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
newRow(row: {id: string, url: string, title: string}) {
|
||||
this.connection?.send("newRow", row)
|
||||
}
|
||||
}
|
||||
|
||||
const flipperClient = newWebviewClient();
|
||||
cosnt plugin = new SeaMammalPlugin();
|
||||
flipperClient.addPlugin();
|
||||
flipperClient.start('Example JS App');
|
||||
plugin.newRow({id: '1', title: 'Dolphin', url: 'example.com'})
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user