UNPKG

reactotron-core-client

Version:

Grants Reactotron clients the ability to talk to a Reactotron server.

40 lines (39 loc) 1.8 kB
"use strict"; /** * Provides helper functions for send state responses. */ const stateResponse = () => reactotron => { return { features: { stateActionComplete: (name, action, important = false) => reactotron.send("state.action.complete", { name, action }, !!important), stateValuesResponse: (path, value, valid = true) => reactotron.send("state.values.response", { path, value, valid }), stateKeysResponse: (path, keys, valid = true) => reactotron.send("state.keys.response", { path, keys, valid }), stateValuesChange: changes => changes.length > 0 && reactotron.send("state.values.change", { changes }), /** sends the state backup over to the server */ stateBackupResponse: state => reactotron.send("state.backup.response", { state }) } }; }; export default stateResponse; export const hasStateResponsePlugin = reactotron => reactotron && "stateActionComplete" in reactotron && typeof reactotron.stateActionComplete === "function" && "stateValuesResponse" in reactotron && typeof reactotron.stateValuesResponse === "function" && "stateKeysResponse" in reactotron && typeof reactotron.stateKeysResponse === "function" && "stateValuesChange" in reactotron && typeof reactotron.stateValuesChange === "function" && "stateBackupResponse" in reactotron && typeof reactotron.stateBackupResponse === "function"; export const assertHasStateResponsePlugin = reactotron => { if (!hasStateResponsePlugin(reactotron)) { throw new Error("This Reactotron client has not had the state responses plugin applied to it. Make sure that you add `use(stateResponse())` before adding this plugin."); } }; //# sourceMappingURL=state-responses.js.map