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

Last updated