$famousDecorator

Manages the creation and handling of isolate scopes.

Isolate scopes are like a namespacing inside plain Angular child scopes, with the purpose of storing properties available only to one particular scope. The scopes are still able to communicate with the parent via events ($emit, $broadcast), yet still have their own $scope properties that will not conflict with the parent or other siblings.

Usage

var isolate = $famousDecorator.ensureIsolate($scope);

$famousDecorator.registerChild($element, $scope, isolate);

$famousDecorator.sequenceWith(
  $scope,
  function(data) { ... },
  function(childScopeId) { ... }
);

Methods

ensureIsolate(scope, element)

Checks the passed in scope for an existing isolate property. If scope.isolate does not already exist, create it.

If the scope is being used in conjunction with an ng-repeat, assign the default ng-repeat index onto the scope.

Param Type Details
scope String

the scope to ensure that the isolate property exists on

element Object

(optional) - the DOM element associated with the target scope

  • Returns: Object the isolated scope object from scope.isolate

registerChild(scope, element, isolate, unregisterCallback)

Register a child isolate's renderNode to the nearest parent that can sequence it, and set up an event listener to remove it when the associated element is destroyed by Angular.

A registerChild event is sent upward with scope.$emit.

Param Type Details
scope String

the scope with an isolate to be sequenced

element String

the element to listen for destruction on

isolate Object

an isolated scope object from $famousDecorator#ensureIsolate

unregisterCallback Function

an optional callback to invoke when unregistration is complete

  • Returns: void

sequenceWith(scope, addMethod, removeMethod)

Attach a listener for registerChild events.

Param Type Details
scope String

the scope to listen on

addMethod Object

the method to apply to the incoming isolate's content to add it to the sequence

removeMethod Object

the method to apply to the incoming isolate's ID to remove it from the sequence

  • Returns: void