@grabjs/superapp-sdk 1.8.10 → 2.0.0-beta.7

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.
@@ -1,327 +0,0 @@
1
- # StorageModule
2
-
3
- ## Description
4
-
5
- Provides persistence storage APIs, which helps the webview have access to persistence information for multiple sessions. Once the user logs out, all saved data will be removed.
6
-
7
- ## Methods
8
-
9
- ### 1. Set boolean value to local storage with key
10
-
11
- **Method name**: `setBoolean`
12
-
13
- **Arguments**
14
-
15
- | Name | Type | Description |
16
- | ----- | ------- | ------------------------------------- |
17
- | key | String | String name of the key |
18
- | value | Boolean | boolean value to put to local storage |
19
-
20
- **Return type**
21
-
22
- `None`
23
-
24
- **Code example**
25
-
26
- ```javascript
27
- import { StorageModule } from '@grab/superapp-sdk';
28
-
29
- // Ideally, initialize this only one and reuse across app.
30
- const storageModule = new StorageModule()
31
-
32
- storageModule.setBoolean(key, value)
33
- .then({ result, error }) => {
34
- if (!!result) {
35
- // There is a valid result.
36
- } else if (!!error) {
37
- // Some error happened.
38
- }
39
- }
40
- ```
41
-
42
- ### 2. Put boolean value to local storage with key
43
-
44
- **Method name**: `getBoolean`
45
-
46
- **Arguments**
47
-
48
- | Name | Type | Description |
49
- | ---- | ------ | ---------------------- |
50
- | key | String | String name of the key |
51
-
52
- **Return type**
53
-
54
- `Optional<Boolean>`
55
-
56
- **Code example**
57
-
58
- ```javascript
59
- import { StorageModule } from '@grab/superapp-sdk';
60
-
61
- // Ideally, initialize this only one and reuse across app.
62
- const storageModule = new StorageModule()
63
-
64
- storageModule.getBoolean(key)
65
- .then({ result, error }) => {
66
- if (!!result) {
67
- // There is a valid result.
68
- } else if (!!error) {
69
- // Some error happened.
70
- }
71
- }
72
- ```
73
-
74
- ### 3. Set int value to local storage with key
75
-
76
- **Method name**: `setInt`
77
-
78
- **Arguments**
79
-
80
- | Name | Type | Description |
81
- | ----- | ------ | --------------------------------- |
82
- | key | String | String name of the key |
83
- | value | Int | int value to put to local storage |
84
-
85
- **Return type**
86
-
87
- `None`
88
-
89
- **Code example**
90
-
91
- ```javascript
92
- import { StorageModule } from '@grab/superapp-sdk';
93
-
94
- // Ideally, initialize this only one and reuse across app.
95
- const storageModule = new StorageModule()
96
-
97
- storageModule.setInt(key, value)
98
- .then({ result, error }) => {
99
- if (!!result) {
100
- // There is a valid result.
101
- } else if (!!error) {
102
- // Some error happened.
103
- }
104
- }
105
- ```
106
-
107
- ### 4. Put int value to local storage with key
108
-
109
- **Method name**: `getInt`
110
-
111
- **Arguments**
112
-
113
- | Name | Type | Description |
114
- | ---- | ------ | ---------------------- |
115
- | key | String | String name of the key |
116
-
117
- **Return type**
118
-
119
- `Optional<Int>`
120
-
121
- **Code example**
122
-
123
- ```javascript
124
- import { StorageModule } from '@grab/superapp-sdk';
125
-
126
- // Ideally, initialize this only one and reuse across app.
127
- const storageModule = new StorageModule()
128
-
129
- storageModule.getInt(key)
130
- .then({ result, error }) => {
131
- if (!!result) {
132
- // There is a valid result.
133
- } else if (!!error) {
134
- // Some error happened.
135
- }
136
- }
137
- ```
138
-
139
- ### 5. Set string value to local storage with key
140
-
141
- **Method name**: `setString`
142
-
143
- **Arguments**
144
-
145
- | Name | Type | Description |
146
- | ----- | ------ | ------------------------------------ |
147
- | key | String | String name of the key |
148
- | value | String | string value to put to local storage |
149
-
150
- **Return type**
151
-
152
- `None`
153
-
154
- **Code example**
155
-
156
- ```javascript
157
- import { StorageModule } from '@grab/superapp-sdk';
158
-
159
- // Ideally, initialize this only one and reuse across app.
160
- const storageModule = new StorageModule()
161
-
162
- storageModule.setString(key, value)
163
- .then({ result, error }) => {
164
- if (!!result) {
165
- // There is a valid result.
166
- } else if (!!error) {
167
- // Some error happened.
168
- }
169
- }
170
- ```
171
-
172
- ### 6. Put string value to local storage with key
173
-
174
- **Method name**: `getString`
175
-
176
- **Arguments**
177
-
178
- | Name | Type | Description |
179
- | ---- | ------ | ---------------------- |
180
- | key | String | String name of the key |
181
-
182
- **Return type**
183
-
184
- `Optional<String>`
185
-
186
- **Code example**
187
-
188
- ```javascript
189
- import { StorageModule } from '@grab/superapp-sdk';
190
-
191
- // Ideally, initialize this only one and reuse across app.
192
- const storageModule = new StorageModule()
193
-
194
- storageModule.getString(key)
195
- .then({ result, error }) => {
196
- if (!!result) {
197
- // There is a valid result.
198
- } else if (!!error) {
199
- // Some error happened.
200
- }
201
- }
202
- ```
203
-
204
- ### 7. Set double value to local storage with key
205
-
206
- **Method name**: `setDouble`
207
-
208
- **Arguments**
209
-
210
- | Name | Type | Description |
211
- | ----- | ------ | ------------------------------------ |
212
- | key | String | String name of the key |
213
- | value | Double | double value to put to local storage |
214
-
215
- **Return type**
216
-
217
- `None`
218
-
219
- **Code example**
220
-
221
- ```javascript
222
- import { StorageModule } from '@grab/superapp-sdk';
223
-
224
- // Ideally, initialize this only one and reuse across app.
225
- const storageModule = new StorageModule()
226
-
227
- storageModule.setDouble(key, value)
228
- .then({ result, error }) => {
229
- if (!!result) {
230
- // There is a valid result.
231
- } else if (!!error) {
232
- // Some error happened.
233
- }
234
- }
235
- ```
236
-
237
- ### 8. Put double value to local storage with key
238
-
239
- **Method name**: `getDouble`
240
-
241
- **Arguments**
242
-
243
- | Name | Type | Description |
244
- | ---- | ------ | ---------------------- |
245
- | key | String | String name of the key |
246
-
247
- **Return type**
248
-
249
- `Optional<Double>`
250
-
251
- **Code example**
252
-
253
- ```javascript
254
- import { StorageModule } from '@grab/superapp-sdk';
255
-
256
- // Ideally, initialize this only one and reuse across app.
257
- const storageModule = new StorageModule()
258
-
259
- storageModule.getDouble(key)
260
- .then({ result, error }) => {
261
- if (!!result) {
262
- // There is a valid result.
263
- } else if (!!error) {
264
- // Some error happened.
265
- }
266
- }
267
- ```
268
-
269
- ### 9. Remove a value from local storage by key
270
-
271
- **Method name**: `remove`
272
-
273
- **Arguments**
274
-
275
- | Name | Type | Description |
276
- | ---- | ------ | ---------------------- |
277
- | key | String | String name of the key |
278
-
279
- **Return type**
280
-
281
- `None`
282
-
283
- **Code example**
284
-
285
- ```javascript
286
- import { StorageModule } from '@grab/superapp-sdk';
287
-
288
- // Ideally, initialize this only one and reuse across app.
289
- const storageModule = new StorageModule()
290
-
291
- storageModule.remove(key)
292
- .then({ result, error }) => {
293
- if (!!result) {
294
- // There is a valid result.
295
- } else if (!!error) {
296
- // Some error happened.
297
- }
298
- }
299
- ```
300
-
301
- ### 10. Remove all values from local storage by key
302
-
303
- **Method name**: `removeAll`
304
-
305
- **Arguments**: `None`
306
-
307
- **Return type**
308
-
309
- `None`
310
-
311
- **Code example**
312
-
313
- ```javascript
314
- import { StorageModule } from '@grab/superapp-sdk';
315
-
316
- // Ideally, initialize this only one and reuse across app.
317
- const storageModule = new StorageModule()
318
-
319
- storageModule.removeAll({})
320
- .then({ result, error }) => {
321
- if (!!result) {
322
- // There is a valid result.
323
- } else if (!!error) {
324
- // Some error happened.
325
- }
326
- }
327
- ```
@@ -1,41 +0,0 @@
1
- # SystemWebViewKitModule
2
-
3
- ## Description
4
-
5
- Open a URL in a system webview.
6
-
7
- ## Methods
8
-
9
- **Method name**: `redirectToSystemWebView`
10
-
11
- **Arguments**:
12
- | Name | Type | Description |
13
- | ---------- | ---------- | ----------------------------- |
14
- | parameters | Parameters | The request parameters. |
15
-
16
- ### Parameters
17
- | Name | Type | Description |
18
- | ---- | ------ | ---------------- |
19
- | url | String | The URL to open. |
20
-
21
- **Return type**: `None`
22
-
23
-
24
- ## Code example
25
-
26
- ```javascript
27
- import { SystemWebViewKitModule } from '@grab/superapp-sdk';
28
-
29
- // initialize once and reuse
30
- const systemWebViewKitModule = new SystemWebViewKitModule();
31
-
32
- // open the system webview
33
- systemWebViewKitModule.redirectToSystemWebView({ url: 'http://wwww.example.com' })
34
- .then({ result, error }) => {
35
- if (!!result) {
36
- // There is a valid result.
37
- } else if (!!error) {
38
- // Some error happened.
39
- }
40
- }
41
- ```