Skip to content

isabella232/es_command

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Command = require('es_command');

// create either from json
msg_string = '{"id":"123","type":"user","action":"setName","params":["ricky"]}';
command = new Command(msg_string);

// or from a hash
msg = {
  id: 123,
  type: "user",
  action: "setName",
  params: ["ricky"]
};
command = new Command(msg);

// Accessors
command.getDataId() // 123
command.getDataType() // "user"
command.getAction() // "setName"
command.getParams() //  ["ricky"]
command.getMessage() // message in hash format
command.getSerializedMessage() // message in json format

// Execute

// run the command's action on a given object
command.execute(current_user); 

// if the command accepts a callback, you can do async/chaining
command.execute(current_user,function(err,result){

  // the command calls current_user.setName("ricky",cb)
  // and setName would run this code whenever it would run cb()

});

About

command and message protocol for ethersheet

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%