UNPKG

@danielkalen/simplybind

Version:

Magically simple, framework-less one-way/two-way data binding for frontend/backend in ~5kb.

33 lines (22 loc) 1.13 kB
BindingMulti = (objects, type, bindingInterface)-> extendState(@, bindingInterface) @isMulti = true @type = type @bindings = bindings = [] for object in objects bindings.push @createBinding(object, type, null, null, bindingInterface) Object.defineProperties @, 'ID': value: bindings[0].ID 'options': value: bindings[0].options 'transforms': value: bindings[0].transforms 'conditions': value: bindings[0].conditions 'updateDep': value: (dep)-> bindings.forEach (binding)-> binding.updateDep(dep, binding) 'pholderValues': get: ()-> bindings[0].pholderValues 'value': get: ()-> bindings.map (binding)-> binding.value 'throttleRate': set: (newRate)-> bindings.forEach (binding)-> binding.throttleRate = newRate 'selfTransform': set: (fn)-> bindings.forEach (binding)-> binding.selfTransform = fn proto = BindingMulti:: = Object.create(BindingInterfacePrivate) Object.keys(Binding::).forEach (methodName)-> proto[methodName] = (a,b)-> # Two arguments is the most ever passed to any method from BindingInterface methdos binding[methodName](a,b) for binding in @bindings return