dataObject.js 806 B

1234567891011121314151617181920212223242526272829303132333435
  1. const dataObject = require('./dataObject');
  2. class dateObjectName extends dataObject {
  3. constructor() {
  4. super();
  5. this.identifier = 'dateObjectName';
  6. // If you intend to treat this object as an (unordered) array, then the next line is required, else remove it
  7. this.set('list', []);
  8. }
  9. }
  10. module.exports = new dateObjectName;
  11. // Loading, you should store a global reference as `require` will supply a new (empty) object every time
  12. window.data = require('dataObjectName');
  13. data.load(function(){
  14. // Callback function in here
  15. });
  16. // Usage as an array:
  17. data.get('list').push({someData: 'some value'});
  18. // Usage as a raw dataObject
  19. data.set('key', 'value');
  20. // Saving:
  21. data.save(function(){
  22. // Callback function in here
  23. });