@danielkalen/simplybind
Version:
Magically simple, framework-less one-way/two-way data binding for frontend/backend in ~5kb.
32 lines (20 loc) • 958 B
text/coffeescript
GroupBinding = (bindingInterface, objects, objectType)->
bindingInterface.selector = bindingInterface.selector.slice(6) # Take out the 'multi:'
extendState(@, = bindingInterface)
= true
= bindings = []
if objects
for object in objects
Object.defineProperties @,
'type': get: ()-> bindings.map (binding)-> binding.type
'value': get: ()-> bindings.map (binding)-> binding.value
proto = GroupBinding:: = Object.create(BindingInterfacePrivate)
Object.keys(Binding::).forEach (methodName)->
proto[methodName] = (a,b,c,d)-> # Four arguments is the most ever passed to any method from BindingInterface methods
for binding in
b = binding if methodName is 'updateSub'
binding[methodName](a,b,c,d)
return
proto.addBinding = (object, objectType)->
.push if not objectType then object else
return