api + plugins examples
Summary: Initial commit for Flipper API for JS apps: 1) Plugin, Connection, Client 2) a bridge to work with WebView proxy app 3) examples of ported plugins: AnalyticsLogging and Fury Reviewed By: danielbuechele Differential Revision: D16753405 fbshipit-source-id: cdd4b863db236b2043f09833aed130035f6738de
This commit is contained in:
committed by
Facebook Github Bot
parent
83f00f2485
commit
46e0abecdf
38
src/utils/js-client/example.js
Normal file
38
src/utils/js-client/example.js
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright 2018-present Facebook.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {FlipperClient} from './api';
|
||||
import {newWebviewClient} from './webviewImpl';
|
||||
import {AnalyticsLoggingFlipperPlugin} from './plugins/analyticsLogging';
|
||||
import {FuryPlugin} from './plugins/fury';
|
||||
|
||||
class FlipperManager {
|
||||
flipperClient: FlipperClient;
|
||||
analyticsPlugin: AnalyticsLoggingFlipperPlugin;
|
||||
furyPlugin: FuryPlugin;
|
||||
|
||||
constructor() {
|
||||
this.flipperClient = newWebviewClient();
|
||||
this.analyticsPlugin = new AnalyticsLoggingFlipperPlugin();
|
||||
this.furyPlugin = new FuryPlugin();
|
||||
this.flipperClient.addPlugin(this.analyticsPlugin);
|
||||
this.flipperClient.addPlugin(this.furyPlugin);
|
||||
this.flipperClient.start();
|
||||
}
|
||||
}
|
||||
|
||||
let flipperManager: ?FlipperManager;
|
||||
|
||||
export function init() {
|
||||
if (!flipperManager) {
|
||||
flipperManager = new FlipperManager();
|
||||
}
|
||||
}
|
||||
|
||||
export function flipper(): ?FlipperManager {
|
||||
return flipperManager;
|
||||
}
|
||||
Reference in New Issue
Block a user