Add onUnhandledMesssage handler

Summary: This diff adds the `client.onUnhandledMessage` handler, to be able to handle messages for which we don't know the names upfront. Some existing plugins that only send one kind of message can benefit from this, as can generic plugins, like the createTablePlugin

Reviewed By: passy

Differential Revision: D24949453

fbshipit-source-id: 0fed81e28aee350632c09ee3bb834f306dc8b100
This commit is contained in:
Michel Weststrate
2020-11-16 13:08:05 -08:00
committed by Facebook GitHub Bot
parent 9a3cd63d55
commit 33e527f39a
3 changed files with 31 additions and 1 deletions

View File

@@ -180,6 +180,15 @@ test('a plugin can receive messages', async () => {
},
}
`);
expect(instance.unhandledMessages.get().length).toBe(0);
sendEvent('unhandled' as any, {hello: 'world'});
expect(instance.unhandledMessages.get()).toEqual([
{
event: 'unhandled',
params: {hello: 'world'},
},
]);
});
test('plugins support non-serializable state', async () => {