Skip to content

v1.2.0

Latest
Compare
Choose a tag to compare
@Omhet Omhet released this 02 Oct 09:29

New methods in callbacks and improved types

Now, in the callbacks you have an access to redux dispatch and getState and signalr invoke methods.

const callbacks = withCallbacks()
  .add('ReceiveMessage', (msg: string) => (dispatch) => {
    dispatch(setText(msg));
  })
  .add('ReceiveRandomNumber', (num: number) => (dispatch, getState, invoke) => {
    const { example } = getState();
    dispatch(setRandomNumber(num));
    invoke('SendMessage', txt + example.text)
  })

Use your custom Dispatch and RootState types in withCallbacks, this way you will have correct typings for dispatch and getState methods in your callbacks

const callbacks = withCallbacks<Dispatch, RootState>()
  .add('CallbackName', () => (dispatch, getState, invoke) => { }