trixta-js-core
  • Overview
  • Installation
  • Quick Start
  • Reference
    • Types
      • Action Related Types
      • Reaction Related Types
      • Other Types
    • Methods
      • Reactions
        • submitTrixtaReactionResponse
        • clearTrixtaReactionResponse
        • clearTrixtaReactionRequestStatus
      • Actions
        • submitTrixtaActionResponse
        • clearTrixtaActionResponse
        • clearTrixtaActionRequestStatus
      • updateTrixtaRole
      • updateTrixtaRoles
      • removeTrixtaRole
      • connectTrixta
      • signoutTrixta
    • Saga Methods
      • respondToTrixtaReactionEffectSaga
      • listenForTrixtaReactionResponse
    • Components
      • Reactions
        • TrixtaReactionComponent
        • RespondToReactionComponent
        • RespondToReactionsComponent
        • TrixtaReactionResponseComponent
      • Actions
        • TrixtaActionComponent
        • TrixtaActionResponseComponent
      • TrixtaAuthComponent
    • Hooks
      • Reactions
        • useTrixtaReaction
        • useRespondToReactionEffect
        • useRespondToReactionResponse
      • Actions
        • useTrixtaAction
      • useTrixtaActionReaction
      • useTrixtaSpace
      • useTrixtaRoles
      • useTrixtaAuth
      • useTrixtaAccess
      • useTrixtaRoleUnmount
    • Redux Selectors
      • Reaction Related Selectors
      • Action Related Selectors
      • Other Selectors
    • Trixta Reducer
    • Trixta Space
    • Trixta Interactions
Powered by GitBook

Copyright (c) 2020 Trixta Inc

On this page

Was this helpful?

Export as PDF
  1. Reference
  2. Saga Methods

listenForTrixtaReactionResponse

This helper method will return the react redux dispatch event for a given roleName and reactionName. This can be used to listen for reactions in saga using the takeEvery effect

Example

export const EXAMPLE_RESPONSE = 'app/EXAMPLE_RESPONSE';
export function functionToDispatch(payload) {
  return {
    type: EXAMPLE_RESPONSE,
    payload,
  }
}
import { put,takeEvery } from 'redux-saga/effects';
import { listenForTrixtaReactionResponse } from '@trixtateam/trixta-js-core';

export default function* checkReactionSaga({ meta, reactionDetails }) {
  const { reactionDetails } = payload;
  const { reactionName, roleName } = meta;

  if(reactionName === 'name of Trixta reaction'){
    yield put(functionToDispatch(reactionDetails.initial_data));
  }
}

export default function* globalSaga() {
yield takeEvery(listenForTrixtaReactionResponse({
  roleName: // name of Trixta role
  reactionName: // name of Trixta reaction
}),checkReactionSaga);
}
Parameter
Description
Type

roleName

Trixta role name

string

reactionName

Trixta reaction name

string

PreviousrespondToTrixtaReactionEffectSagaNextComponents

Last updated 2 years ago

Was this helpful?