-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added DSLocalStorageAdapter.
- Loading branch information
Showing
18 changed files
with
715 additions
and
73 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,50 @@ | ||
@doc overview | ||
@id how | ||
@name How do I...? | ||
@name How do I? | ||
@description | ||
|
||
#### How do I serialize data before it's saved? | ||
Before the data store sends date to an adapter, you may need to transform it to a custom request object of yours. | ||
|
||
Define a global serialization method: | ||
```js | ||
DSHttpAdapter.defaults.serialize = function (data) { | ||
DSProvider.defaults.serialize = function (resourceName, data) { | ||
// custom payload format | ||
return { | ||
payload: data | ||
}; | ||
}; | ||
``` | ||
|
||
Define a serialization method for a specific resource: | ||
```js | ||
DS.defineResource({ | ||
name: 'user', | ||
serialize: function (resourceName, user) { | ||
return { | ||
payload: user | ||
}; | ||
} | ||
}); | ||
``` | ||
|
||
#### How do I deserialize data? | ||
When an adapter returns data to the data store from the server, for example, you may need to extract data from a custom response object of yours. | ||
|
||
Define a global deserialization method: | ||
```js | ||
DSHttpAdapter.defaults.deserialize = function (data) { | ||
DSProvider.defaults.deserialize = function (resourceName, data) { | ||
// extract data from custom payload format | ||
return data ? data.payload : data; | ||
}; | ||
``` | ||
|
||
Define a deserialization method for a specific resource: | ||
```js | ||
DS.defineResource({ | ||
name: 'user', | ||
deserialize: function (resourceName, data) { | ||
return data.data.embedded; | ||
} | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
f1c1228
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#63