-
Notifications
You must be signed in to change notification settings - Fork 936
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standardizes the plugin's interface. (#87)
* Updates plugins to have the same reactotron interface. * Changes the plugin interface to () => reactotron => {}. * Removes the useless decorate plugin. * Adds an npm run e2e for my own sanity.
- Loading branch information
Showing
23 changed files
with
114 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
import RS from 'ramdasauce' | ||
|
||
// apisauce uses axios, so let's deconstruct that format | ||
const convertResponse = (source) => { | ||
const url = RS.dotPath('config.url', source) | ||
const method = RS.dotPath('config.method', source) | ||
const requestData = RS.dotPath('config.data', source) | ||
const requestHeaders = RS.dotPath('config.headers', source) | ||
const duration = RS.dotPath('duration', source) | ||
const status = RS.dotPath('status', source) | ||
const body = RS.dotPath('data', source) | ||
const responseHeaders = RS.dotPath('headers', source) | ||
const request = { url, method, data: requestData, headers: requestHeaders } | ||
const response = { body, status, headers: responseHeaders } | ||
|
||
return [ request, response, duration ] | ||
} | ||
|
||
/** | ||
* Sends an apisauce response to the server. | ||
*/ | ||
export default config => { | ||
export default () => reactotron => { | ||
return { | ||
features: { | ||
apisauce: (source) => { | ||
// apisauce uses axios, so let's deconstruct that format | ||
const url = RS.dotPath('config.url', source) | ||
const method = RS.dotPath('config.method', source) | ||
const requestData = RS.dotPath('config.data', source) | ||
const requestHeaders = RS.dotPath('config.headers', source) | ||
const duration = RS.dotPath('duration', source) | ||
const status = RS.dotPath('status', source) | ||
const body = RS.dotPath('data', source) | ||
const responseHeaders = RS.dotPath('headers', source) | ||
const request = { url, method, data: requestData, headers: requestHeaders } | ||
const response = { body, status, headers: responseHeaders } | ||
|
||
config.ref.apiResponse(request, response, duration) | ||
} | ||
apisauce: (source) => reactotron.apiResponse(...convertResponse(source)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
/** | ||
* Sends API request/response information. | ||
*/ | ||
export default config => { | ||
export default () => reactotron => { | ||
return { | ||
features: { | ||
apiResponse: (request, response, duration) => | ||
config.send('api.response', { request, response, duration }) | ||
reactotron.send('api.response', { request, response, duration }) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
/** | ||
* Provides 4 features for logging. log & debug are the same. | ||
*/ | ||
export default ({ send }) => { | ||
export default () => reactotron => { | ||
return { | ||
features: { | ||
log: (message) => send('log', { level: 'debug', message }), | ||
debug: (message) => send('log', { level: 'debug', message }), | ||
warn: (message) => send('log', { level: 'warn', message }), | ||
error: (message) => send('log', { level: 'error', message }) | ||
log: (message) => reactotron.send('log', { level: 'debug', message }), | ||
debug: (message) => reactotron.send('log', { level: 'debug', message }), | ||
warn: (message) => reactotron.send('log', { level: 'warn', message }), | ||
error: (message) => reactotron.send('log', { level: 'error', message }) | ||
} | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
packages/reactotron-core-client/src/plugins/state-responses.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
/** | ||
* Provides helper functions for send state responses. | ||
*/ | ||
export default config => { | ||
export default () => reactotron => { | ||
return { | ||
features: { | ||
stateActionComplete: (name, action) => | ||
config.send('state.action.complete', { name, action }), | ||
reactotron.send('state.action.complete', { name, action }), | ||
|
||
stateValuesResponse: (path, value, valid = true) => | ||
config.send('state.values.response', { path, value, valid }), | ||
reactotron.send('state.values.response', { path, value, valid }), | ||
|
||
stateKeysResponse: (path, keys, valid = true) => | ||
config.send('state.keys.response', { path, keys, valid }), | ||
reactotron.send('state.keys.response', { path, keys, valid }), | ||
|
||
stateValuesChange: changes => | ||
config.send('state.values.change', { changes }) | ||
reactotron.send('state.values.change', { changes }) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
packages/reactotron-core-client/test/plugin-decorator-test.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.