@webkrafters/react-observable-context 4.1.0-rc.4 → 4.1.0-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +6 -34
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -30,7 +30,7 @@ Subscribing component decides which context state properties' changes to trigger
30
30
 
31
31
  **Moniker:** Eagle Eye
32
32
 
33
- **Usage:** Please see <b><a href="#getting-started">Getting Started</a></b> section
33
+ **Usage:** Please see <b><a href="#getting-started">Getting Started</a></b>.
34
34
 
35
35
  **Demo:** [Play with the app on codesandbox](https://codesandbox.io/s/github/webKrafters/react-observable-context-app)\
36
36
  If sandbox fails to load app, please refresh dependencies on its lower left.
@@ -39,7 +39,7 @@ If sandbox fails to load app, please refresh dependencies on its lower left.
39
39
  npm i -S @webkrafters/react-observable-context\
40
40
  npm install --save @webkrafters/react-observable-context
41
41
 
42
- May also see <b><a href="#changes">What's Changed?</a></b> section below.
42
+ May also see <b><a href="#changes">What's Changed?</a></b>.
43
43
 
44
44
  <h1 id="toc">Table of Contents</h1>
45
45
 
@@ -97,30 +97,7 @@ import React, { useEffect, useState } from 'react';
97
97
  import ObservableContext from './context';
98
98
  import Ui from './ui';
99
99
 
100
- const DEFAULT_C = 36;
101
-
102
- const updateHooks = {
103
- resetState: ( ...args ) => {
104
- console.log( 'resetting state with >>>> ', JSON.stringify( args ) );
105
- return true;
106
- },
107
- setState: ( ...args ) => {
108
- console.log( 'merging following into state >>>> ', JSON.stringify( args ) );
109
- return true;
110
- }
111
- };
112
-
113
- const storageStub = {
114
- clone( data ) { return your_clone_function( data ) },
115
- data: null,
116
- getItem( key ) { return this.data },
117
- removeItem( key ) { this.data = null },
118
- setItem( key, data ) { this.data = data }
119
- };
120
-
121
- const Provider = ({ c = DEFAULT_C }) => {
122
-
123
- const storeRef = useRef();
100
+ const Provider = ({ c = 36 }) => {
124
101
 
125
102
  const [ state, setState ] = useState(() => ({
126
103
  a: { b: { c, x: { y: { z: [ 2022 ] } } } }
@@ -135,12 +112,7 @@ const Provider = ({ c = DEFAULT_C }) => {
135
112
  }, [ c ]);
136
113
 
137
114
  return (
138
- <ObservableContext.Provider
139
- prehooks={ updateHooks }
140
- ref={ storeRef }
141
- storage={ storageStub }
142
- value={ state }
143
- >
115
+ <ObservableContext.Provider value={ state }>
144
116
  <Ui />
145
117
  </ObservableContext.Provider>
146
118
  );
@@ -317,9 +289,9 @@ A special property path [@@STATE](#fullstate-selectorkey) may be used to access
317
289
  ## Provider
318
290
  The Provider component is a property of the `React-Observable-Context` context object. As a `React.context` based provider, it accepts the customary `children` and `value` props. It also accepts **2** optional props: <a href="#prehooks"><code>prehooks</code></a> and <a href="#storage"><code>storage</code></a>.
319
291
 
320
- External direct access to the context store may be obtained via the `ref` attribute. Please see a [Provider Usage](#provider-usage) sample below.
292
+ External direct access to the context store may be obtained via the `ref` attribute. Please see a [Provider Usage](#provider-usage) sample.
321
293
 
322
- Routinely, the `value` prop is initialized with the full initial state. It may only be updated with parts of the state which are changing. Please see a [Provider Usage](#provider-usage) sample below.
294
+ Routinely, the `value` prop is initialized with the full initial state. It may only be updated with parts of the state which are changing. Please see a [Provider Usage](#provider-usage) sample.
323
295
 
324
296
  <h2 id="selector-map">Selector Map</h2>
325
297
  A selector map is an object holding key:value pairs.<br />
package/package.json CHANGED
@@ -133,5 +133,5 @@
133
133
  "test:watch": "eslint --fix && jest --updateSnapshot --watchAll"
134
134
  },
135
135
  "types": "dist/main/index.d.ts",
136
- "version": "4.1.0-rc.4"
136
+ "version": "4.1.0-rc.6"
137
137
  }