2.1.0 • Published 21 days ago

@gecut/lit-helper v2.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
21 days ago

Gecut Data Manager

Receiver Concept

receiver of data and cache on memory ram and update

Sender Concept

sender of data and update dependencies data, for example when create new todo, should update todo list data

How can i use ?

step by step to use @gecut/data-manager

First Step

define type of receivers and senders

declare global {
  interface GecutReceiverServices {
    readonly 'todo-storage': TodoInterface[];
  }
  interface GecutSenderServices {
    readonly 'new-todo': TodoInterface;
  }
}

Second Step

define dataManager from a new instance of DataManager class

const dataManager = new DataManager(
  {
    'todo-storage': {
      receiverFunction() {
        // receive todo-storage data and return
        return api.storage.query();
      },
    },
  },
  {
    'new-todo': {
      // when send data update todo-storage
      dependencies: ['todo-storage'],
      async senderFunction(newTodo) {
        // send new todo data to back-end
        await api.new.mutate(newTodo);
      },
    },
  },
);

Third Step

// define this in Component Class and use
// receiver decorator has autoUpdate (automatic requestUpdate)
@receiver('todo-storage', dataManager)
todoStorage!: TodoInterface[];

Fourth Step

// use this for send data
dataManager.senders['new-todo']?.send({
  status: true,
  message: textInputValue,
});
2.0.3

21 days ago

2.1.0

21 days ago

2.0.2

1 month ago

2.0.1

2 months ago

2.0.0

2 months ago

1.2.3

4 months ago

1.2.2

4 months ago

1.2.0

4 months ago

1.1.0

4 months ago

1.2.1

4 months ago

1.0.1

5 months ago

1.0.0

5 months ago

1.0.0-pre1

5 months ago