Guest User

Untitled

a guest
Feb 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. // ==========================================================================
  2. // StoreTest
  3. // ==========================================================================
  4.  
  5. StoreTest = SC.Object.create({
  6.  
  7. // Configure the way you want your data stored here
  8. store: SC.store().from(SC.LocalStorage).from(
  9. SC.AtomRestAdaptor.create({ only: '/tasks', format: SC.JSON_FORMAT }),
  10. SC.AtomRestAdaptor.create({ only: '/session', format: SC.XML_FORMAT }));
  11.  
  12. // When you are in development mode, this array will be populated with
  13. // any fixtures you create for testing and loaded automatically in your
  14. // main method. When in production, this will be an empty array.
  15. FIXTURES: []
  16.  
  17. }) ;
  18.  
  19. // creating an editing context is the same thing...
  20.  
  21. var context = SC.EditingContext.create().from(Todos.store);
  22.  
  23. or
  24.  
  25. var context = Todos.store.newEditingContext() ;
  26.  
  27. // you can commit a context and all changed records will commit...
  28.  
  29. context.commitChanges() ;
  30.  
  31. // or you can discard changes and the context will refresh any records from
  32. // their data source.
  33.  
  34. context.discardChanges() ;
  35.  
  36. context.recordDidChange() // invoke whenever a record changes.
  37. context.isDirty // changes whenever a record has changed.
  38.  
  39. //---
  40.  
  41. /** Request that the source context load the attributes for the specified
  42. query options.
  43. */
  44. loadRecordsForContext: function(context, params) ;
  45. refreshRecordsForContext: function(context, records) ;
  46.  
  47. updateRecordsFromSourceContext: function(dataHashes, sourceContext) ;
  48.  
  49. /** Request that the source context take the updated attributes for the named
  50. record. */
  51. commitRecordsForContext: function(context, records) ;
  52.  
  53. //callback
  54. commitRecordsDidSucceedForSourceContext: function(sourceContext, records) ;
  55. commitRecordsDidFailForSourceContext: function(sourceContext, records) ;
  56.  
  57. /** Request that the source context create new set of attributes for the
  58. record. It should invoke a callback on the context when complete to set a
  59. permenant guid. */
  60. createRecordsForContext: function(context, records) ;
  61.  
  62. createRecordsDidSucceedForSourceContext: function(sourceContext, records) ;
  63. createRecordsDidFailForSourceContext: function(sourceContext, records) ;
  64.  
  65. /** Request that the source context delete the attributes associated with the
  66. passed records. It should invoke a callback o nthe context when complete.
  67. */
  68. destroyRecordsForContext: function(context, records) ;
  69.  
  70. destroyRecordsDidSucceedForSourceContext: function(sourceContext, records) ;
  71. destroyRecordsDidFailForSourceContext: function(sourceContext, records) ;
Add Comment
Please, Sign In to add comment