Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance connection #16

Merged
merged 1 commit into from
May 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 35 additions & 34 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,43 @@ const error = {
NO_STORE: 'NO_STORE',
};

const createDebugger = () => {
return (store: any) => (next: any) => (action: { type: string }) => {
if (currentConnection == null) {
addPlugin({
getId() {
return 'flipper-plugin-redux-debugger';
},
onConnect(connection: any) {
currentConnection = connection;
const createDebugger = () => (store: any) => {
if (currentConnection == null) {
addPlugin({
getId() {
return 'flipper-plugin-redux-debugger';
},
onConnect(connection: any) {
currentConnection = connection;

currentConnection.receive(
'dispatchAction',
(data: any, responder: any) => {
console.log('flipper redux dispatch action data', data);
// respond with some data
if (store) {
store.dispatch({ type: data.type, ...data.payload });
currentConnection.receive(
'dispatchAction',
(data: any, responder: any) => {
console.log('flipper redux dispatch action data', data);
// respond with some data
if (store) {
store.dispatch({ type: data.type, ...data.payload });

responder.success({
ack: true,
});
} else {
responder.success({
error: error.NO_STORE,
message: 'store is not setup in flipper plugin',
});
}
},
);
},
onDisconnect() {},
runInBackground() {
return true;
},
});
}
responder.success({
ack: true,
});
} else {
responder.success({
error: error.NO_STORE,
message: 'store is not setup in flipper plugin',
});
}
},
);
},
onDisconnect() {},
runInBackground() {
return true;
},
});
}

return (next: any) => (action: { type: string }) => {
let startTime = Date.now();
let before = store.getState();
let result = next(action);
Expand Down