Sha256: d1037ec2bb669ada330960b4c021966de466768c59e0d84503a0cac484fb3135

Contents?: true

Size: 1.98 KB

Versions: 11

Compression:

Stored size: 1.98 KB

Contents

// ==========================================================================
// Project:   SC.Statechart - A Statechart Framework for SproutCore
// Copyright: ©2010, 2011 Michael Cohen, and contributors.
//            Portions @2011 Apple Inc. All rights reserved.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================

/*globals SC */

/**
  @class

  Represents contextual information for whenever a state handles a triggered
  route. In additional to retaining contextual information, you can also
  use the object to retry trigging the state's route handler. Useful in cases
  where you need to defer the handling of the route for a later time.

  @see SC.State

  @extends SC.Object
  @author Michael Cohen
*/
SC.StateRouteHandlerContext = SC.Object.extend(
  /** @scope SC.StateRouteContext.prototype */{

  /**
    The state that constructed this context object.

    @property {SC.State}
  */
  state: null,

  /**
    The location that caused the state's route to be
    triggered.

    @type String
  */
  location: null,

  /**
    The parameters that were supplied to the state's
    handler when the state's route was triggered.

    @type Hash
  */
  params: null,

  /**
    The handler that got invoked when the state's
    route was triggered. This can either be a reference
    to the actual method or a name of the method.

    @property {Function|String}
  */
  handler: null,

  /**
    Used to retry invoking the state's handler for when
    the state's route gets triggered. When called this will
    essentially perform the same call as when the handler
    was originally triggered on state.
  */
  retry: function() {
    var state = this.get('state'),
        params = this.get('params'),
        handler = this.get('handler');

    if (SC.typeOf(handler) === SC.T_STRING) {
      handler = state[handler];
    }

    if (SC.typeOf(handler) === SC.T_FUNCTION) {
      handler.apply(state, [params]);
    }
  }

});

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sproutcore-1.11.0 lib/frameworks/sproutcore/frameworks/statechart/system/state_route_handler_context.js
sproutcore-1.11.0.rc3 lib/frameworks/sproutcore/frameworks/statechart/system/state_route_handler_context.js
sproutcore-1.11.0.rc2 lib/frameworks/sproutcore/frameworks/statechart/system/state_route_handler_context.js
sproutcore-1.11.0.rc1 lib/frameworks/sproutcore/frameworks/statechart/system/state_route_handler_context.js
sproutcore-1.10.3.1 lib/frameworks/sproutcore/frameworks/statechart/system/state_route_handler_context.js
sproutcore-1.10.2 lib/frameworks/sproutcore/frameworks/statechart/system/state_route_handler_context.js
sproutcore-1.10.1 lib/frameworks/sproutcore/frameworks/statechart/system/state_route_handler_context.js
sproutcore-1.10.0 lib/frameworks/sproutcore/frameworks/statechart/system/state_route_handler_context.js
sproutcore-1.10.0.rc.3 lib/frameworks/sproutcore/frameworks/statechart/system/state_route_handler_context.js
sproutcore-1.10.0.rc.2 lib/frameworks/sproutcore/frameworks/statechart/system/state_route_handler_context.js
sproutcore-1.10.0.rc.1 lib/frameworks/sproutcore/frameworks/statechart/system/state_route_handler_context.js