codos

1.0.3 • Public • Published

Codos: The back-end data is directly responded to the foreground through websocket

This module is divided into two ends, client and server. These two segments cannot be confused.

installing

npm install codos

examples

Synchronization is mainly achieved by modifying attributes, such as Vue

server

let codosServer = new DServer();
let result = codosServer.setStore(store)
store = result;
codosServer.bindServer(server, "/data");
codosServer.start();

client

// initialization
let client = new SClient();
// Set the path of the binding
client.setPath("/data");
// Bind store
client.setStore(store.state);
// Return value
let result = client.getStore();
// Monitor data change
result.on("change", (target: any, key: string, value: any, ...data: any) => {
  Vue.set(target, key, value);
})
client.start();

In this way, as long as the back-end data changes, it will be pushed to the front-end through websocket, which can cooperate with any framework to achieve the effect of dynamic updateIn the above example, as long as the 'result' of the server changes, for example:

result.ax = 12;

Such updates will be sent directly to the client

Readme

Keywords

none

Package Sidebar

Install

npm i codos

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

43.3 kB

Total Files

24

Last publish

Collaborators

  • app_net