@laserware/stasis
    Preparing search index...

    Function call

    • Creates an Effect description that instructs the middleware to call the function fn with args as arguments.

      fn can be either a normal or a Generator function.

      The middleware invokes the function and examines its result.

      If the result is an Iterator object, the middleware will run that Generator function, just like it did with the startup Generators (passed to the middleware on startup). The parent Generator will be suspended until the child Generator terminates normally, in which case the parent Generator is resumed with the value returned by the child Generator. Or until the child aborts with some error, in which case an error will be thrown inside the parent Generator.

      If fn is a normal function and returns a Promise, the middleware will suspend the Generator until the Promise is settled. After the promise is resolved the Generator is resumed with the resolved value, or if the Promise is rejected an error is thrown inside the Generator.

      If the result is not an Iterator object nor a Promise, the middleware will immediately return that value back to the saga, so that it can resume its execution synchronously.

      When an error is thrown inside the Generator, if it has a try/catch block surrounding the current yield instruction, the control will be passed to the catch block. Otherwise, the Generator aborts with the raised error, and if this Generator was called by another Generator, the error will propagate to the calling Generator.

      Type Parameters

      • Fn extends (...args: any[]) => any

      Parameters

      • fn: Fn

        A Generator function, or normal function which either returns a Promise as result, or any other value.

      • ...args: Parameters<Fn>

        An array of values to be passed as arguments to fn

      Returns CallEffect<SagaReturnType<Fn>>

    • Same as call([context, fn], ...args) but supports passing a fn as string. Useful for invoking object's methods, i.e. yield call([localStorage, 'getItem'], 'redux-saga')

      Type Parameters

      • Ctx extends { [P in string]: (this: Ctx, ...args: any[]) => any }
      • Name extends string

      Parameters

      Returns CallEffect<SagaReturnType<Ctx[Name]>>

    • Same as call([context, fn], ...args) but supports passing context and fn as properties of an object, i.e. yield call({context: localStorage, fn: localStorage.getItem}, 'redux-saga'). fn can be a string or a function.

      Type Parameters

      • Ctx extends { [P in string]: (this: Ctx, ...args: any[]) => any }
      • Name extends string

      Parameters

      • ctxAndFnName: { context: Ctx; fn: Name }
      • ...args: Parameters<Ctx[Name]>

      Returns CallEffect<SagaReturnType<Ctx[Name]>>

    • Same as call(fn, ...args) but supports passing a this context to fn. This is useful to invoke object methods.

      Type Parameters

      • Ctx
      • Fn extends (this: Ctx, ...args: any[]) => any

      Parameters

      • ctxAndFn: [Ctx, Fn]
      • ...args: Parameters<Fn>

      Returns CallEffect<SagaReturnType<Fn>>

    • Same as call([context, fn], ...args) but supports passing context and fn as properties of an object, i.e. yield call({context: localStorage, fn: localStorage.getItem}, 'redux-saga'). fn can be a string or a function.

      Type Parameters

      • Ctx
      • Fn extends (this: Ctx, ...args: any[]) => any

      Parameters

      • ctxAndFn: { context: Ctx; fn: Fn }
      • ...args: Parameters<Fn>

      Returns CallEffect<SagaReturnType<Fn>>