You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Store value is available at the end of the promise chain.
70
70
console.log('Value of foo: ', store.get('foo'));
71
+
})
72
+
.then(() => {
73
+
console.log('Value of bar: ', store.get('bar'));
71
74
});
72
75
}
73
-
74
-
store.initialize()(callback);
75
76
```
76
77
77
78
### Express Example
@@ -95,7 +96,7 @@ app.use((req, res, next) => {
95
96
// Get request Id from store
96
97
app.get('/', (req, res) => {
97
98
constreqId=store.get('reqId');
98
-
console.log(`[${reqId}]`);
99
+
console.log(`Request Id: ${reqId}`);
99
100
100
101
res.json({ message:'Hello World' });
101
102
});
@@ -109,12 +110,29 @@ app.listen(port, () => console.log(`Example app listening on port ${port}!`));
109
110
110
111
## API Docs
111
112
113
+
### initialize()
114
+
115
+
Initialize the async store based on the adapter provided.
116
+
117
+
-`@param {AsyncStoreAdapter} [adapter=AsyncStoreAdapter.DOMAIN]` - Async store adapter to use.
118
+
-`@returns {(params: AsyncStoreParams) => void}` - Returns a function that takes a callback which will be triggered once the store has been initialized.
-`@params {any} properties`: Properties to set in store.
149
+
-`@params {any} properties` - Persist properties to set in store.
132
150
-`@returns {void}`
133
151
134
152
```js
@@ -137,21 +155,21 @@ store.set({ foo: 'Hello', bar: 'World' });
137
155
138
156
### get()
139
157
140
-
It gets a value by a key from the store.
158
+
Gets a value by a key from the store.
141
159
142
-
-`@params {string} key`: Key specifies property of store.
143
-
-`@returns {any}`
160
+
-`@params {string} key` - Key to get from the store.
161
+
-`@returns {any}` - Returns the value persisted in the store by `key` which could be `null` if key not found. Any error caught during the retrieval will be thrown and cascaded.
144
162
145
163
```js
146
164
constfoo=store.get('foo');
147
165
```
148
166
149
167
### find()
150
168
151
-
It gets a value by a key from the store. If anything fails, it returns null without emitting error event.
169
+
Gets a value by a key from the store. If anything fails, it returns `null` without emitting error event.
152
170
153
-
-`@params {string} key`: Key specifies property of store.
154
-
-`@returns {any}`
171
+
-`@params {string} key` - Key to get from the store.
172
+
-`@returns {any}` - Returns the value persisted in the store by `key` which could be `null` if key not found. Any error caught during the retrieval will be supressed and `null` value is returned.
0 commit comments