@@ -22,7 +22,7 @@ With this component, you can create data that is stored throughout the session.
2222
2323When the page is closed, the stored data is deleted. You can think of this data as a ** global state** .
2424
25- You can handle data changes from the ``` Session.onSet((data) => { }) ``` event and set the ``` state ``` of the components.
25+ You can handle data changes from the ``` Session.onSet(function UniqueName (data) { }) ``` event and set the ``` state ``` of the components.
2626
2727##### Features
2828- Set and get data from all components.
@@ -48,9 +48,11 @@ class Counter extends Component {
4848 }
4949 }
5050 componentDidMount () {
51- Session . onSet ( (data ) => {
51+ const counter = (data ) => {
5252 this .setState ({ counter: data[" counter" ] });
53- });
53+ };
54+
55+ Session .onSet (counter);
5456 }
5557 render () {
5658 return (
@@ -116,7 +118,7 @@ Descriptions and configuration settings for component properties.
116118 - ```key``` ```{string}``` session item key.
117119 - ```value``` ```{Object|string}``` session item value, if you are using browser storage, it can only take ```{string}```.
118120
119- - ** ``` Session.gey (key) ``` Get session item.**
121+ - ** ``` Session.get (key) ``` Get session item.**
120122 - ```key``` ```{string}``` session item key.
121123
122124- ** ``` Session.remove(key) ``` Remove session item by key.**
@@ -126,9 +128,12 @@ Descriptions and configuration settings for component properties.
126128
127129- ** ``` Session.clear() ``` Clear all items.**
128130
131+ - ** ``` Session.unmount(callbackName) ``` Unmount callback function.**
132+ - ```callbackName``` ```{string}``` callback unique name.
133+
129134##### Events
130135
131- - ** ``` Session.onSet((data) => { /* do things */}) ``` Triggered when session data changes.**
136+ - ** ``` Session.onSet(function UniqueName (data) { /* do things */ }) ``` Triggered when session data changes.**
132137
133138 - ```data``` new data set.
134139
0 commit comments