Socket
Book a DemoInstallSign in
Socket

duplex-binding

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

duplex-binding

for Node.bind/Polymer

latest
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

Duplex Binding

for Node.bind/Polymer


var DuplexBinding = require('duplex-binding')

var template = document.querySelector('template')
template.bindingDelegate = new PolymerExpressions()
template.model = {
  counter: {
    value: 0
  }
}
setInterval(function() {
  template.model.counter.value && template.model.counter.value--
}, 1000)

function MyCustomElement() {}

MyCustomElement.prototype = Object.create(HTMLElement.prototype)

MyCustomElement.prototype.createdCallback = function() {
  this.model = {
    value: 0
  }
}

MyCustomElement.prototype.attachedCallback = function() {
  var self = this;
  this.addEventListener('click', function() {
    self.model.value++
  })
}

DuplexBinding(
  MyCustomElement.prototype,
  'value',
  'model.value',
  onValueChanged
)

function onValueChanged(newValue, oldValue) {
  console.log('%s -> %s', oldValue, newValue)
}

document.register('my-element', MyCustomElement)

FAQs

Package last updated on 27 Mar 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts