Skip to content

Commit 463b4b9

Browse files
committed
Document sdk-init hook. Update apidocs.
1 parent eeeee26 commit 463b4b9

File tree

5 files changed

+31
-316
lines changed

5 files changed

+31
-316
lines changed

.core/app/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ export const App = async () => {
3030

3131
await deps().loadAll('allHooks');
3232

33+
/**
34+
* @api {Hook} sdk-init sdk-init
35+
* @apiName sdk-init
36+
* @apiDescription Called after reactium-hooks.js DDD artifacts are loaded, to allow
37+
* the Reactium SDK singleton to be extended before the init hook.
38+
* @apiGroup Hooks
39+
*/
3340
Reactium.Hook.runSync('sdk-init', Reactium);
3441
await Reactium.Hook.run('sdk-init', Reactium);
3542

docs/api_data.js

+11-157
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,17 @@ define({ "api": [
842842
"filename": ".core/sdk/routing/index.js",
843843
"groupTitle": "Hooks"
844844
},
845+
{
846+
"type": "Hook",
847+
"url": "sdk-init",
848+
"title": "sdk-init",
849+
"name": "sdk-init",
850+
"description": "<p>Called after reactium-hooks.js DDD artifacts are loaded, to allow the Reactium SDK singleton to be extended before the init hook.</p>",
851+
"group": "Hooks",
852+
"version": "0.0.0",
853+
"filename": ".core/app/index.js",
854+
"groupTitle": "Hooks"
855+
},
845856
{
846857
"type": "Hook",
847858
"url": "store-create",
@@ -1417,44 +1428,6 @@ define({ "api": [
14171428
"filename": "node_modules/@atomic-reactor/reactium-sdk-core/lib/named-exports/is-container.js",
14181429
"groupTitle": "ReactHook"
14191430
},
1420-
{
1421-
"type": "ReactHook",
1422-
"url": "useReduxState(select,shouldUpdate,domain)",
1423-
"title": "useReduxState()",
1424-
"description": "<p>Similar to React useState(), returns selected redux state, and action dispatching function, as the first and second elements of an array.</p> <p>Takes an optional shouldUpdate callback (see useSelect), which does a shallow comparison of previous and current selected state by default. The update callback returned expects to be called with an object, and will cause a dispatch: { type: 'DOMAIN_UPDATE', domain, // the passed domain update, // object passed to update }</p> <p>Note: the boilerplate redux reducer created with <code>arcli component</code> will target action dispatched from this hoook.</p>",
1425-
"parameter": {
1426-
"fields": {
1427-
"Parameter": [
1428-
{
1429-
"group": "Parameter",
1430-
"type": "Function",
1431-
"optional": true,
1432-
"field": "select",
1433-
"description": "<p>Optional select callback (see useSelect), which selects for the domain by default.</p>"
1434-
},
1435-
{
1436-
"group": "Parameter",
1437-
"type": "Function",
1438-
"optional": true,
1439-
"field": "shouldUpdate",
1440-
"description": "<p>Optional shouldUpdate callback (see useSelect), which does a shallow comparison of previous and current selected state by default.</p>"
1441-
},
1442-
{
1443-
"group": "Parameter",
1444-
"type": "String",
1445-
"optional": false,
1446-
"field": "domain",
1447-
"description": "<p>The targeted redux domain.</p>"
1448-
}
1449-
]
1450-
}
1451-
},
1452-
"name": "useReduxState",
1453-
"group": "ReactHook",
1454-
"version": "0.0.0",
1455-
"filename": "node_modules/@atomic-reactor/use-select/lib/named-exports/redux.js",
1456-
"groupTitle": "ReactHook"
1457-
},
14581431
{
14591432
"type": "ReactHook",
14601433
"url": "useRefs()",
@@ -1540,64 +1513,6 @@ define({ "api": [
15401513
"filename": ".core/sdk/named-exports/roles.js",
15411514
"groupTitle": "ReactHook"
15421515
},
1543-
{
1544-
"type": "ReactHook",
1545-
"url": "useSelect(params)",
1546-
"title": "useSelect()",
1547-
"description": "<p>React hook for subscribing to only the updates from Redux store that you care about, and no more. This is superior to <code>react-redux</code> connect, in that your component will not update on every dispatch, only those state changes you have specifically targeted.</p>",
1548-
"parameter": {
1549-
"fields": {
1550-
"Parameter": [
1551-
{
1552-
"group": "Parameter",
1553-
"type": "Mixed",
1554-
"optional": false,
1555-
"field": "params",
1556-
"description": "<ol> <li>Callback function taking current state object from Redux store, and returning what you care about, or</li> <li>an Object with <code>select</code>, <code>shouldUpdate</code> and <code>returnMode</code> props.</li> </ol>"
1557-
},
1558-
{
1559-
"group": "Parameter",
1560-
"type": "Function",
1561-
"optional": false,
1562-
"field": "params.select",
1563-
"description": "<p>Callback function taking current state object from Redux store, and returning what you care about.</p>"
1564-
},
1565-
{
1566-
"group": "Parameter",
1567-
"type": "Function",
1568-
"optional": true,
1569-
"field": "params.shouldUpdate",
1570-
"description": "<p>Callback function object with 2 properties <code>newState</code> and <code>prevState</code>, containing the current results of the select function, and the previous results of the select function, respectively. Returns true if your component should update, otherwise false. By default, <code>useSelect</code> will do a shallow comparison.</p>"
1571-
},
1572-
{
1573-
"group": "Parameter",
1574-
"type": "String",
1575-
"optional": true,
1576-
"field": "params.returnMode",
1577-
"defaultValue": "state",
1578-
"description": "<p><code>state</code> to get the current state, <code>ref</code> to get the whole React reference object (for more realtime updates), and <code>get</code> for a getter function that takes object-path</p>"
1579-
}
1580-
]
1581-
}
1582-
},
1583-
"name": "useSelect",
1584-
"group": "ReactHook",
1585-
"examples": [
1586-
{
1587-
"title": "Simple.js",
1588-
"content": "import React from 'react';\nimport { useSelect } from '@atomic-reactor/use-select';\n\n// given a Redux state of { \"Simple\": {\"foo\": { \"bar\": \"baz\" }}}\nexport default () => {\n // Simple select callback: will update the component only when state.Simple.foo.bar changes no more.\n const baz = useSelect(state => state.Simple.foo.bar);\n return (\n <div>\n {baz}\n </div>\n );\n};",
1589-
"type": "json"
1590-
},
1591-
{
1592-
"title": "Advanced.js",
1593-
"content": "import React from 'react';\nimport { useSelect } from '@atomic-reactor/use-select';\n\n// given a Redux state of {\n// \"Advanced\": {\n// \"foo\": { \"bar\": \"baz\" },\n// \"hello\": \"world\",\n// }\n//}\nexport default () => {\n // Advanced select callback: will update the component only conditions of shouldUpdate are true.\n // All other Redux state changes are ignored.\n const Advanced = useSelect({\n select: state => state.Advanced,\n\n shouldUpdate: ({newState, prevState}) => {\n // newState and prevState are current and previous outcome of select callback above\n return newState.foo.bar !== prevState.foo.bar || newState.hello !== prevState.hello;\n },\n });\n\n return (\n <div>\n {Advanced.foo.bar}\n {Advanced.hello}\n </div>\n );\n};",
1594-
"type": "json"
1595-
}
1596-
],
1597-
"version": "0.0.0",
1598-
"filename": "node_modules/@atomic-reactor/use-select/lib/named-exports/redux.js",
1599-
"groupTitle": "ReactHook"
1600-
},
16011516
{
16021517
"type": "ReactHook",
16031518
"url": "useSettingGroup(group)",
@@ -1659,24 +1574,6 @@ define({ "api": [
16591574
"filename": "node_modules/@atomic-reactor/reactium-sdk-core/lib/named-exports/useStatus.js",
16601575
"groupTitle": "ReactHook"
16611576
},
1662-
{
1663-
"type": "ReactHook",
1664-
"url": "useStore()",
1665-
"title": "useStore()",
1666-
"description": "<p>Just gimme the store damnit! This React hook provides the Redux store when used on a component declared within the Store Provider.</p>",
1667-
"name": "useStore",
1668-
"group": "ReactHook",
1669-
"examples": [
1670-
{
1671-
"title": "MyComponent.js",
1672-
"content": "import React, { useEffect } from 'react';\nimport { useStore } from '@atomic-reactor/use-select';\n\nexport default () => {\n const { dispatch, getState, subscribe } = useStore();\n let count = getState();\n\n useEffect(() => {\n const unsubscribe = subscribe(() => {\n count = getState();\n });\n\n return unsubscribe;\n });\n\n return (\n <div>\n <button onClick={() => dispatch({ type: 'BUTTON_CLICK' })}>\n Click {count}\n </button>\n </div>\n );\n};",
1673-
"type": "json"
1674-
}
1675-
],
1676-
"version": "0.0.0",
1677-
"filename": "node_modules/@atomic-reactor/use-select/lib/named-exports/redux.js",
1678-
"groupTitle": "ReactHook"
1679-
},
16801577
{
16811578
"type": "ReactHook",
16821579
"url": "useSyncState(initialState)",
@@ -3388,49 +3285,6 @@ define({ "api": [
33883285
"filename": "node_modules/@atomic-reactor/reactium-sdk-core/lib/named-exports/fullscreen.js",
33893286
"groupTitle": "Reactium.Utilities"
33903287
},
3391-
{
3392-
"type": "Function",
3393-
"url": "ec(Component)",
3394-
"title": "ec()",
3395-
"description": "<p>ec, short for &quot;easy connect&quot; is a stripped down version of the redux <code>connect</code> function, which will provide your component with any Redux state properties under the name matching your component class (if applicable), as well as a <code>getState</code> function property.</p>",
3396-
"name": "ec",
3397-
"parameter": {
3398-
"fields": {
3399-
"Parameter": [
3400-
{
3401-
"group": "Parameter",
3402-
"type": "Component",
3403-
"optional": false,
3404-
"field": "Component",
3405-
"description": "<p>the React component to be decorated with Redux state.</p>"
3406-
},
3407-
{
3408-
"group": "Parameter",
3409-
"type": "domain",
3410-
"optional": true,
3411-
"field": "domain",
3412-
"description": "<p>domain or object path to get from state. if not provided, will used Component.name property.</p>"
3413-
}
3414-
]
3415-
}
3416-
},
3417-
"group": "Reactium.Utilities",
3418-
"examples": [
3419-
{
3420-
"title": "MyComponent/index.js",
3421-
"content": "import MyComponent from './MyComponent';\nimport { ec } from '@atomic-reactor/use-select';\n\nexport ec(MyComponent);",
3422-
"type": "json"
3423-
},
3424-
{
3425-
"title": "MyComponent/MyComponent.js",
3426-
"content": "import React, { Component } from 'react';\n\nclass MyComponent extends Component {\n render() {\n // getState prop provided by ec\n const state = this.props.getState();\n // foo property provided by ec\n const foo = this.props.foo;\n\n // Given that Redux store has an property MyComponent with property `foo`\n return (\n <div>\n {state.MyComponent.foo}\n {foo}\n </div>\n );\n }\n}\n\nMyComponent.defaultProps = {\n getState: () => {},\n foo: null,\n};\n\nexport default MyComponent;",
3427-
"type": "json"
3428-
}
3429-
],
3430-
"version": "0.0.0",
3431-
"filename": "node_modules/@atomic-reactor/use-select/lib/named-exports/redux.js",
3432-
"groupTitle": "Reactium.Utilities"
3433-
},
34343288
{
34353289
"type": "Function",
34363290
"url": "Reactium.Utils.abbreviatedNumber(number)",

0 commit comments

Comments
 (0)