6. STORE
• Falls back to in-memory storage
• Never worry about whether a persistent store exists
• Support for time-based expiration of data
• Extensible
7. STORE API
• store a value
• amplify.store( key, value )
• get a value
• amplify.store( key )
• amplify.store() // all values
8. STORE API
• expiration
• amplify.store( key, value, { expires: 1000 } )
• specific store
• amplify.store.sessionStorage( key, value )
• amplify.store.sessionStorage( key )
9. REQUEST
• abstraction for requesting data
• separates requesting data from:
• retrieving data
• parsing data
• caching data
10. REQUEST API
• define a request
• amplify.request.define( resourceId, resourceType, settings )
• make a request
• amplify.request( resourceId, data, callback )
17. MANIPULATING DATA
• change the data format from third party services
• change the status (success/error) of a request
• many services always respond with a 200 OK HTTP status
18. REQUEST DECODERS
• allowyou to parse data before calling the success or error
callback
• change the data passed to the callback
• change the status of the request
20. REQUEST CACHING
• boolean: in-memory
• number: in-memory with expiration (in ms)
• “persist”: delegate to amplify.store()
• “sessionStorage”: delegate to amplify.store.sessionStorage()
• easy to create new cache types
21. PUB/SUB
• not on initial list of features
• we usually use custom events in jQuery
• needed a simple system to post messages for amplify.request
23. PUB/SUB API
• publish a message
• amplify.publish( topic )
• amplify.publish( topic, arg1, arg2 )
• returns boolean indicating whether any subscription returned
false
24. REQUEST MESSAGES
• request.before, request.before.ajax
• do something before a request
• prevent a request
• request.success, request.error, request.complete
• do something after a request