src/basis/data/resolve.js
function resolveValue(context, fn, source, property, factoryContext){
  var oldAdapter = context[property] || null;
  var newAdapter = null;

  // as functions could be a value, invoke only functions with factory property
  // i.e. source -> function(){ /* factory code */ }).factory === FACTORY
  // apply only for top-level resolveValue() invocation
  if (source && fn !== resolveAdapterProxy && basis.fn.isFactory(source))
    source = source.call(factoryContext || context, factoryContext || context);

  if (source && source.bindingBridge)
  {
    if (!oldAdapter || oldAdapter.source !== source)
      newAdapter = new BBResolveAdapter(context, fn, source, DEFAULT_CHANGE_ADAPTER_HANDLER);
    else
      newAdapter = oldAdapter;

    source = resolveValue(newAdapter, resolveAdapterProxy, source.bindingBridge.get(source), 'next');
  }

  if (property && oldAdapter !== newAdapter)
  {
    var cursor = oldAdapter;

    // drop old adapter chain
    while (cursor)
    {
      var adapter = cursor;
      adapter.detach();
      cursor = adapter.next;
      adapter.next = null;
    }

    if (newAdapter)
      newAdapter.attach(RESOLVEVALUE_DESTROY_ADAPTER_HANDLER);

    context[property] = newAdapter;
  }

  return source;
}
function resolveValue(context, fn, source, property, factoryContext){
  var oldAdapter = context[property] || null;
  var newAdapter = null;

  // as functions could be a value, invoke only functions with factory property
  // i.e. source -> function(){ /* factory code */ }).factory === FACTORY
  // apply only for top-level resolveValue() invocation
  if (source && fn !== resolveAdapterProxy && basis.fn.isFactory(source))
    source = source.call(factoryContext || context, factoryContext || context);

  if (source && source.bindingBridge)
  {
    if (!oldAdapter || oldAdapter.source !== source)
      newAdapter = new BBResolveAdapter(context, fn, source, DEFAULT_CHANGE_ADAPTER_HANDLER);
    else
      newAdapter = oldAdapter;

    source = resolveValue(newAdapter, resolveAdapterProxy, source.bindingBridge.get(source), 'next');
  }

  if (property && oldAdapter !== newAdapter)
  {
    var cursor = oldAdapter;

    // drop old adapter chain
    while (cursor)
    {
      var adapter = cursor;
      adapter.detach();
      cursor = adapter.next;
      adapter.next = null;
    }

    if (newAdapter)
      newAdapter.attach(RESOLVEVALUE_DESTROY_ADAPTER_HANDLER);

    context[property] = newAdapter;
  }

  return source;
}
function resolveValue ( context , fn , source , property , factoryContext ) { var oldAdapter = context [ property ] || null ; var newAdapter = null ; // as functions could be a value, invoke only functions with factory property // i.e. source -> function(){ /* factory code */ }).factory === FACTORY // apply only for top-level resolveValue() invocation if ( source && fn !== resolveAdapterProxy && basis . fn . isFactory ( source ) ) source = source . call ( factoryContext || context , factoryContext || context ) ; if ( source && source . bindingBridge ) { if ( ! oldAdapter || oldAdapter . source !== source ) newAdapter = new BBResolveAdapter ( context , fn , source , DEFAULT_CHANGE_ADAPTER_HANDLER ) ; else newAdapter = oldAdapter ; source = resolveValue ( newAdapter , resolveAdapterProxy , source . bindingBridge . get ( source ) , 'next' ) ; } if ( property && oldAdapter !== newAdapter ) { var cursor = oldAdapter ; // drop old adapter chain while ( cursor ) { var adapter = cursor ; adapter . detach ( ) ; cursor = adapter . next ; adapter . next = null ; } if ( newAdapter ) newAdapter . attach ( RESOLVEVALUE_DESTROY_ADAPTER_HANDLER ) ; context [ property ] = newAdapter ; } return source ; }
Resolve value from source.
Resolve value from source .