Objective Redux

Redux made better, objectively.

getControllerFromSagaContext

function getControllerFromSagaContext<C>(controller: Controller|ModelConstructor<C>): Generator<any, undefined, C>

Gets a controller instance from the saga context.

Template Parameters

<C>
The type of controller that will be returned. This type is inferred and does not need to be specified in
TypeScript.

Parameters

controller: Controller|ModelConstructor<C>
The controller class of which an instance should be retrieved.

Returns

Generator
A generator that yields an instance of the provided controller or null if there is no ObjectiveStore
instance in the saga's context.

Examples

// Also works with a StateController
class MyController extends StatelessController {
  // ...
}

function* foo(): any {
  const myController = yield getControllerFromSagaContext(MyController);
}