Skip to content
soliton4 edited this page Dec 9, 2014 · 4 revisions

#savable - type modifier

Stability: 3 - Stable

requires

implies

the savable modifier automatically triggers the unique modifier. so savable types are also unique types.

provides an adapter to load and save instances.

the new operator of savable types results in a promise of the type. this is due to the fact that a asynchronous loading routine my be required to load the data.

  class type savable MyData {
    member1: "default",
    member2: "default"
  };
  
  MyData data = *new MyData("id1");

the id logic is inherited from the unique modifier.

.save()

a promising "save" member function is provided to trigger saving.

  data.member1 = "something";
  *data.save(); // save and wait for save to finish

api

Stability: 2 - Unstable

the api works pretty satisfying so far, but i need more experience with it to make if final.

  class SaveHandler {
    registerClass: (par)*{
      return {
        /* par: {
             propertiesAr: [{ name: "name", value: "value" }]
           }
        */
        save: (par)*{
        },
        /* par: {
             properties: { id: { value: "id value" } }
           }
        */
        load: (par)*{
          // return a object 
        },
        /* par: {
             properties: { id: { value: "id value" } }
           }
        */
        delete: (par)*{
        }
    };
  }
};

promiseland.classSystem.setSaveHandler(new SaveHandler());

####achievement concentrate on your program logic, not on how to shovel data in and out.

continue reading about [dynamic type usage](dynamic type usage)

Clone this wiki locally