0.2.0 • Published 10 years ago

bindable-call v0.2.0

Weekly downloads
38
License
BSD
Repository
github
Last release
10 years ago

Makes it easy to bind asynchronous function calls. Alt ci

Example

var bindableCall = require("bindable-call"),
username = "user",
password = "password";

var loginCall = bindableCall(function(next) {
  login(username, password, next);
});



loginCall.bind("loading").once().to(function(loading) {
  
}).now();

loginCall.bind("error").once().to(function(error) {
  console.log(error.message);
}).now();

loginCall.bind("data").once().to(function(data) {
  console.log(data);
}).now();

loginCall.bind("response").once().to(function(response) {
  console.log(response.error, response.data);
}).now();

Mojo.js Example

login.coffee

class LoginView extends mojo.View

  ###
  ###
  
  paper: require("./login.pc")
  
  ###
  ###
  
  bindings:
    "loginCall.loading" : "loading"
    "loginCall.error"   : "error"
  
  ###
  ###
  
  login: () ->
  
    @set "loginCall", bindableCall (next) =>
      mediator.execute "login", {
        username: @get("username"),
        password: @get("password")
      }, next
      

login.pc

{{#if: loading }}
  loading...
{{/else}}

  {{#if: error }}
    {{ error.message }}
  {{/}}
  
  <input type="text" name="username" data-bind="{{ model: this }}"></input>
  <input type="text" name="password" data-bind="{{ model: this }}"></input>
{{/}}
0.2.0

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

11 years ago

0.0.1

11 years ago