 		data.bindings[prop]?.destroy()
 
 		if binding?
-			# if isSimpleBinding(binding)
-			# 	data.bindings[prop] = new SimpleBinding @, prop, binding, ctx
-			# else
-			data.bindings[prop] = Binding.factory @, prop, binding, component, ctx
+			data.bindings[prop] = RendererBinding.factory @, prop, binding, component, ctx
 
 		return

					conn.updateItem()
			return

		constructor: (@obj, @prop, binding, @component, @ctx) ->
			assert.lengthOf binding, 2
			assert.isFunction binding[0]
			assert.isArray binding[1]

			item = @item = @obj._ref or @obj
			if @listensOnComponentObjectChange = @component.onObjectChange?
				@component.onObjectChange onComponentObjectChange, @

			# properties
			@func = binding[0]
			@args = @component.objectsOrder

			# connections
			connections = @connections ||= []
			for elem in binding[1]
				if isArray(elem)
					connections.push Connection.factory @, elem[0], elem[1]

			# update
			`//<development>`
			@updatePending = false
			@updateLoop = 0
			`//</development>`
			Object.seal @

			@update()

		getDefaultValue = (binding) ->
			val = binding.obj[binding.prop]
			switch typeof val
				when 'string'
					''
				when 'number'
					0
				when 'boolean'
					false
				else
					null

		update: ->
			unless @args
				return

			`//<development>`
			if @updatePending
				if @updateLoop > MAX_LOOPS
					return
				if ++@updateLoop is MAX_LOOPS
					log.error "Potential loop detected. Property binding '#{@prop}' on item '#{@item.toString()}' has been disabled."
					return
			else
				@updateLoop = 0
			`//</development>`

			result = utils.tryFunction @func, @ctx, @args
			unless result?
				result = getDefaultValue @

			if typeof result is 'number' and not isFinite(result)
				result = getDefaultValue @

			`//<development>`
			@updatePending = true
			`//</development>`
			@obj[@prop] = result
			`//<development>`
			@updatePending = false
			`//</development>`
			return

		destroy: ->
			# destroy connections
			for connection in @connections
				connection.destroy()

			# remove from the list
			@obj._impl.bindings[@prop] = null

			# clear props
			@args = null
			utils.clear @connections
			if @listensOnComponentObjectChange
				@component.onObjectChange.disconnect onComponentObjectChange, @

			pool.push @
			return

'use strict'

Binding = require 'neft-binding'

module.exports = (impl) ->

	class RendererBinding extends Binding
		pool = []

		@factory = (obj, prop, binding, component, ctx) ->
			if elem = pool.pop()
				RendererBinding.call elem, obj, prop, binding, component, ctx
			RendererBinding.New obj, prop, binding, component, ctx, elem

		@New = (obj, prop, binding, component, ctx, target) ->
			target ?= new RendererBinding obj, prop, binding, component, ctx
			Binding.New binding, ctx, target
			target.update()
			target

		onComponentObjectChange = (id) ->
			for conn in @connections
