6.36.4 • Published 4 months ago

@talend/react-cmf-cqrs v6.36.4

Weekly downloads
1,445
License
Apache-2.0
Repository
github
Last release
4 months ago

Content Management Framework for CQRS (aka cmf-cqrs)

This is a library to help you to build configurable React App with CQRS pattern.

Travis CI NPM dependencies devdependencies

Content

This package provides tools to deal with cqrs backend allowing websocket handling :

  • acknowledgement actions
  • ACKDispatcher component
  • Smart Websocket middleware
  • ACK reducer

How it works

  • to start the websocket with smartWebsocket middleware :
ws = new SmartWebsocket(urlPrefix, {
	onOpen: () => dispatch({ type: SOCKET_ON_OPEN }),
	onClose: () => dispatch({ type: SOCKET_ON_CLOSE }),
	onMessage: messageEvent => {
		socketListener.forEach(func => func(messageEvent, dispatch, getState, ws));
	},
	onError: errorEvent => {
		dispatch({ type: SOCKET_ON_CLOSE, event: errorEvent });
	},
	onPing: event => {
		ws.pingTimeoutId = event.pingTimeoutId;
	},
	onPingTimeout: () => {
		dispatch({ type: SOCKET_ON_PING_TIMEOUT });
	},
	...socketOptions,
});

socketOptions is optionnal but allows websocket configuration from middleware instanciation within your application.

{
	checkInterval: 5000,
	pingInterval: 10000,
	pingTimeoutDelay: SOCKET_ON_PING_TIMEOUT_DELAY,
}
  • checkInterval : max duration between 2 websocket connections trials if closed
  • pingInterval : duration between ping message from the webapp to the server, like a heartbeat of the connection
  • pingTimeoutDelay : duration after which a PING message not being answered by a PONG will trigger a SOCKET_ON_PING_TIMEOUT and force close of the current connection

In onMessage event, you should get middleware handlers as well.

  • On the reducer, actions handled :
    • ACK_ADD_CONTEXT : Used to add a new request on stack
    • ACK_RECEIVE_MESSAGE : Used when a message come from the ws
    • ACK_DELETE : Used when you want to delete a handler

SocketMiddleware

This middleware serve two purpose

listening to action dispatched to the reducer, and be able to send message trought the websocket

listening to message comming from the websocket and dispatching message to the reducer

Configuration

import cmf from '@talend/react-cmf';
import cqrsModule, { middlewares as cqrsMiddlewares } from '@talend/react-cmf-cqrs';

const websocketMiddleware = cqrsMiddlewares.createWebsocketMiddleware(
	API['cqrs-websocket'],
	[...actionListeners],
	[...socketListener],
	{ ...socketOptions },
);

cmf.bootstrap({
	appId: 'app',
	// ...
	modules: [cqrsModule]
	middlewares: [websocketMiddleware]
});

the action listener recieve for each action the store state ,before the action is applied the action dispatched to the store reducer the new state resulting from the action to be applied

the value returned by the actionListener get sent trought the websocket.

/** an example of an action listener sending all action trought the ws **/
function myActionListener(previousState, action, nextState) {
	return JSON.stringify(action);
}

the socketListener recieve for each message the messageEvent containing all information about the message recieved the store.dispatch function so you can dispatch an action the store.getState function in case you want to check the store state before doing anything the smartWebSocket itself so the listener can access to the websocket itself (eg: datastreams pong socket listener that get timeoutId and clear it before it's execution)

/** an example of an message listener dispatching each message recieved **/
function myMessageListener(messageEvent, dispatch, getState, smartWebSocket) {
	dispatch({type: 'MESSAGE RECIEVED', message: JSON.parse(messageEvent.data);})
}

Additionnaly the websocket middleware dispatch action on socket state change and on message being recieved.

on socket connection open success the following action get dispatched

{ type: SOCKET_ON_OPEN }

on socket connection being closed the following action get dispatched

{ type: SOCKET_ON_CLOSE }

on socket connection being closed by an error the following action get dispatched

{ type: SOCKET_ON_ERROR, event: errorEvent }

on socket connection receiving a message, no action get dispatched but socketListeners are called which will take care of dispactching action or not or even do something else

on socket connection timeout reached, the following action get dispatched

{ type: SOCKET_ON_PING_TIMEOUT }
6.36.4

4 months ago

6.36.3

4 months ago

6.36.2

4 months ago

6.36.1

5 months ago

6.36.0

5 months ago

6.35.0

6 months ago

6.34.0

6 months ago

6.33.0

6 months ago

6.32.0

7 months ago

6.31.0

7 months ago

6.30.0

7 months ago

6.29.0

8 months ago

6.28.0

8 months ago

6.27.0

8 months ago

6.26.0

8 months ago

6.25.0

9 months ago

6.24.0

9 months ago

6.24.1

9 months ago

6.23.0

9 months ago

6.22.0

9 months ago

6.21.0

9 months ago

6.20.0

10 months ago

6.19.0

10 months ago

6.18.0

10 months ago

6.17.0

10 months ago

6.16.0

11 months ago

6.15.1

11 months ago

6.15.0

11 months ago

6.14.2

11 months ago

6.14.1

11 months ago

6.14.0

11 months ago

7.0.0-alpha.1

11 months ago

6.13.0

12 months ago

6.12.0

12 months ago

6.11.1

12 months ago

6.12.0-alpha.0

12 months ago

6.11.0

12 months ago

6.10.1

1 year ago

6.10.0

1 year ago

6.9.1

1 year ago

6.9.0

1 year ago

6.8.0

1 year ago

6.7.0

1 year ago

6.6.0

1 year ago

6.5.1

1 year ago

6.5.0

1 year ago

6.4.0

1 year ago

6.3.1

1 year ago

6.3.0

1 year ago

6.2.4

1 year ago

6.2.3

1 year ago

6.2.2

1 year ago

6.2.1

1 year ago

6.2.0

1 year ago

5.31.0

1 year ago

6.1.8

1 year ago

5.30.3

1 year ago

6.1.7

1 year ago

5.30.2

1 year ago

6.1.6

1 year ago

6.1.5

1 year ago

6.1.4

1 year ago

5.30.1

1 year ago

6.1.2

1 year ago

6.1.3

1 year ago

6.1.1

1 year ago

5.30.0

1 year ago

6.1.0

1 year ago

6.0.1

1 year ago

6.0.0

1 year ago

5.29.4

1 year ago

5.29.3

1 year ago

5.29.2

1 year ago

5.29.1

1 year ago

5.29.0

1 year ago

5.28.1-alpha.0

1 year ago

6.0.0-ds.0

1 year ago

5.29.0-alpha.0

1 year ago

5.28.0

1 year ago

6.0.0-alpha.43

1 year ago

5.27.1

1 year ago

5.27.0

1 year ago

6.0.0-alpha.41

1 year ago

6.0.0-alpha.42

1 year ago

6.0.0-alpha.40

1 year ago

5.26.0

1 year ago

6.0.0-alpha.39

1 year ago

6.0.0-alpha.38

1 year ago

6.0.0-alpha.37

1 year ago

6.0.0-alpha.35

1 year ago

6.0.0-alpha.36

1 year ago

6.0.0-alpha.34

1 year ago

6.0.0-alpha.29

1 year ago

6.0.0-alpha.30

1 year ago

6.0.0-alpha.31

1 year ago

6.0.0-alpha.32

1 year ago

6.0.0-alpha.33

1 year ago

5.25.0

1 year ago

6.0.0-alpha.28

1 year ago

6.0.0-alpha.27

1 year ago

6.0.0-alpha.26

1 year ago

6.0.0-alpha.25

1 year ago

6.0.0-alpha.24

1 year ago

6.0.0-alpha.21

1 year ago

6.0.0-alpha.22

1 year ago

6.0.0-alpha.23

1 year ago

6.0.0-y.0

1 year ago

6.0.0-alpha.20

1 year ago

6.0.0-alpha.19

1 year ago

5.24.0

1 year ago

6.0.0-alpha.18

1 year ago

6.0.0-alpha.17

1 year ago

5.23.0

1 year ago

6.0.0-alpha.16

1 year ago

6.0.0-alpha.15

1 year ago

6.0.0-alpha.14

1 year ago

6.0.0-alpha.13

1 year ago

5.22.1

1 year ago

5.22.0

1 year ago

6.0.0-alpha.12

1 year ago

5.21.0

1 year ago

6.0.0-alpha.11

1 year ago

5.20.0

1 year ago

5.20.0-alpha.0

1 year ago

5.19.0

1 year ago

5.18.0

1 year ago

5.17.0

1 year ago

5.16.0

1 year ago

5.15.0

1 year ago

5.14.0

2 years ago

5.14.0-alpha.0

2 years ago

5.13.0

2 years ago

5.12.0

2 years ago

5.11.0

2 years ago

6.0.0-alpha.9

2 years ago

6.0.0-alpha.10

2 years ago

5.10.3

2 years ago

5.9.2

2 years ago

5.7.2

2 years ago

5.10.2

2 years ago

5.9.1

2 years ago

6.0.0-alpha.8

2 years ago

6.0.0-alpha.7

2 years ago

5.10.1

2 years ago

5.10.0

2 years ago

5.7.1

2 years ago

6.0.0-alpha.3

2 years ago

6.0.0-alpha.4

2 years ago

6.0.0-alpha.5

2 years ago

6.0.0-alpha.6

2 years ago

6.0.0-alpha.1

2 years ago

6.0.0-alpha.2

2 years ago

6.0.0-alpha.0

2 years ago

5.9.0

2 years ago

5.8.0

2 years ago

5.7.0

2 years ago

5.6.0

2 years ago

5.1.3

2 years ago

5.5.0

2 years ago

5.5.0-alpha.0

2 years ago

5.4.0

2 years ago

5.3.0

2 years ago

4.38.2

2 years ago

4.38.1

2 years ago

4.38.0

2 years ago

5.2.0

2 years ago

5.2.0-y.4

2 years ago

5.2.0-y.3

2 years ago

5.2.0-y.2

2 years ago

5.2.0-y.1

2 years ago

5.1.2

2 years ago

5.2.0-y.0

2 years ago

4.37.1

2 years ago

5.1.2-alpha.2

2 years ago

5.1.1

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

4.37.0

2 years ago

4.36.3

2 years ago

4.36.2

2 years ago

4.36.1

2 years ago

4.36.0

2 years ago

4.35.0

2 years ago

4.34.1

2 years ago

4.34.0

2 years ago

4.32.2

2 years ago

4.33.0

2 years ago

4.32.1

2 years ago

4.32.0

2 years ago

4.32.0-0

2 years ago

4.31.0

2 years ago

4.30.0

2 years ago

4.29.0

2 years ago

4.28.1

2 years ago

4.28.0

2 years ago

4.27.0

2 years ago

4.26.0

2 years ago

4.26.1

2 years ago

4.26.2

2 years ago

4.25.0

2 years ago

4.25.0-0

2 years ago

4.24.0

2 years ago

4.23.0

2 years ago

4.23.0-0

2 years ago

4.21.1

2 years ago

4.22.0

2 years ago

4.21.0

2 years ago

4.19.1

2 years ago

4.20.0

2 years ago

4.19.0

2 years ago

4.19.0-1

2 years ago

4.19.0-0

2 years ago

4.18.0

2 years ago

4.17.0

2 years ago

4.16.0

2 years ago

4.15.0

2 years ago

4.14.0

2 years ago

4.14.0-1

2 years ago

4.14.0-0

2 years ago

4.13.0

2 years ago

4.13.0-1

2 years ago

4.10.3

2 years ago

4.13.0-0

2 years ago

4.12.0

2 years ago

4.11.0

2 years ago

4.10.2

2 years ago

4.10.1

2 years ago

4.10.0

2 years ago

4.9.0

2 years ago

4.8.2

2 years ago

4.9.0-2

2 years ago

4.9.0-1

2 years ago

4.9.0-0

2 years ago

4.8.1

2 years ago

4.8.0

2 years ago

4.7.0

2 years ago

4.7.0-1

2 years ago

4.7.0-0

2 years ago

4.6.0

2 years ago

4.5.0

2 years ago

4.4.0

2 years ago

4.3.0

3 years ago

4.2.0

3 years ago

4.1.1

3 years ago

4.1.0

3 years ago

4.0.1

3 years ago

3.9.12

3 years ago

3.12.1

3 years ago

3.9.11

3 years ago

4.0.0

3 years ago

3.12.0

3 years ago

3.9.10

3 years ago

3.9.9

3 years ago

3.9.8

3 years ago

3.11.0

3 years ago

3.9.7

3 years ago

3.9.6

3 years ago

3.8.4

3 years ago

3.8.3

3 years ago

3.8.2

3 years ago

3.9.5

3 years ago

3.10.0

3 years ago

3.9.4

3 years ago

3.9.3

3 years ago

3.9.2

3 years ago

3.9.1

3 years ago

3.10.0-alpha.0

3 years ago

3.9.0

3 years ago

3.8.1

3 years ago

3.8.0

3 years ago

3.8.0-1

3 years ago

3.7.2

3 years ago

3.6.3

3 years ago

3.7.1

3 years ago

3.6.2

3 years ago

3.8.0-0

3 years ago

3.7.0

3 years ago

3.7.0-0

3 years ago

3.6.1

3 years ago

3.6.0

3 years ago

3.6.0-1

3 years ago

3.6.0-0

3 years ago

3.5.0

3 years ago

3.4.0

3 years ago

2.6.19

3 years ago

3.4.0-0

3 years ago

3.3.0

3 years ago

3.2.1

3 years ago

3.2.0

3 years ago

3.1.0

3 years ago

2.12.2

3 years ago

3.0.0

3 years ago

2.12.1

3 years ago

2.12.0

3 years ago

2.6.18

3 years ago

2.11.0

3 years ago

2.6.17

3 years ago

2.6.16

3 years ago

2.6.15

3 years ago

2.10.0

3 years ago

2.6.14

3 years ago

2.6.13

3 years ago

2.6.12

3 years ago

2.6.11

3 years ago

2.9.0

3 years ago

2.6.10

3 years ago

2.6.9

3 years ago

2.8.0

3 years ago

2.6.8

3 years ago

2.6.7

3 years ago

2.6.6

3 years ago

2.6.5

3 years ago

2.6.4

3 years ago

2.7.0

3 years ago

2.6.3

3 years ago

2.6.2

3 years ago

2.6.1

3 years ago

2.6.0

3 years ago

2.5.1-0

3 years ago

2.5.0

3 years ago

2.5.0-1

3 years ago

2.4.1

3 years ago

2.5.0-0

3 years ago

2.4.0

3 years ago

2.4.0-0

3 years ago

2.3.1

3 years ago

2.3.0

3 years ago

2.2.0

3 years ago

2.2.0-0

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.13.0

3 years ago

1.12.0

3 years ago

1.12.0-1

3 years ago

1.12.0-0

3 years ago

1.11.0

3 years ago

1.10.1

3 years ago

1.10.0-webpack4

3 years ago

1.10.0

3 years ago

1.10.0-1

3 years ago

1.9.1

3 years ago

1.10.0-0

3 years ago

1.9.0

3 years ago

2.0.0-0

3 years ago

1.9.0-1

3 years ago

1.9.0-0

3 years ago

1.8.0

3 years ago

1.7.0

3 years ago

1.6.3

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.0

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.4.0-0

3 years ago

1.3.0

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.211.0-0

3 years ago

0.210.2

3 years ago

0.210.1

3 years ago

0.210.0

3 years ago

0.210.0-0

3 years ago

0.209.0

3 years ago

0.208.1-0

3 years ago

0.197.1-tdp

3 years ago

0.208.0

3 years ago

0.207.1

3 years ago

0.207.0

3 years ago

0.206.0

3 years ago

0.206.0-2

3 years ago

0.206.0-1

3 years ago

0.206.0-0

3 years ago

0.205.0

3 years ago

0.205.0-0

3 years ago

0.204.1

3 years ago

0.204.0

3 years ago

0.203.1

3 years ago

0.203.0

3 years ago

0.202.0

4 years ago

0.201.1

4 years ago

0.201.0

4 years ago

0.201.0-2

4 years ago

0.201.0-1

4 years ago

0.201.0-0

4 years ago

0.200.2

4 years ago

0.200.1

4 years ago

0.200.0

4 years ago

0.200.0-0

4 years ago

0.199.0

4 years ago

0.198.3

4 years ago

0.198.2

4 years ago

0.198.1

4 years ago

0.198.0

4 years ago

0.197.0

4 years ago

0.196.0

4 years ago

0.195.0

4 years ago

0.194.0

4 years ago

0.193.0

4 years ago

0.192.0

4 years ago

0.191.0

4 years ago

0.190.0

4 years ago

0.189.0

4 years ago

0.188.0

4 years ago

0.187.1

4 years ago

0.187.0

4 years ago

0.186.0

4 years ago

0.185.0

4 years ago

0.184.0

4 years ago

0.183.0

4 years ago

0.182.0

4 years ago

0.181.0

4 years ago

0.180.0

4 years ago

0.179.0

4 years ago

0.178.0

4 years ago

0.177.0

4 years ago

0.176.0

4 years ago

0.175.0

4 years ago

0.174.0

4 years ago

0.173.0

4 years ago

0.172.0

4 years ago

0.171.0

4 years ago

0.170.0

4 years ago

0.169.0

4 years ago

0.168.0

4 years ago

0.167.0

4 years ago

0.166.0

4 years ago

0.165.0

4 years ago

0.164.0

4 years ago

0.163.1

4 years ago

0.163.0

4 years ago

0.162.0

4 years ago

0.161.0

4 years ago

0.160.0

4 years ago

0.159.0

4 years ago

0.158.0

4 years ago

0.157.0

4 years ago

0.156.0

4 years ago

0.155.3-0

4 years ago

0.155.1

4 years ago

0.155.2-0

4 years ago

0.155.1-0

4 years ago

0.155.0

4 years ago

0.154.0

4 years ago

0.153.0

4 years ago

0.152.0

4 years ago

0.151.0

4 years ago

0.150.0

4 years ago

0.149.0

4 years ago

0.148.0

4 years ago

0.147.0

4 years ago

0.146.0

4 years ago

0.145.0

4 years ago

0.144.0

4 years ago

0.143.0

4 years ago

0.142.0

4 years ago

0.141.0

4 years ago

0.140.0

4 years ago

0.139.0

4 years ago

0.138.0

4 years ago

0.137.0

4 years ago

0.136.0

4 years ago

0.135.0

4 years ago

0.134.0

4 years ago

0.133.0

4 years ago

0.132.0

4 years ago

0.131.0

4 years ago

0.130.0

4 years ago

0.129.0

4 years ago

0.128.0

4 years ago

0.127.0

4 years ago

0.126.0

4 years ago

0.125.0

4 years ago

0.124.0

4 years ago

0.123.0

4 years ago

0.122.0

4 years ago

0.121.0

4 years ago

0.120.0

4 years ago

0.119.0

4 years ago

0.118.0

4 years ago

0.117.0

4 years ago

0.116.0

4 years ago

0.115.0

4 years ago

0.114.0

4 years ago

0.113.1

4 years ago

0.113.0

4 years ago

0.112.0

4 years ago

0.111.0

4 years ago

0.110.0

4 years ago

0.109.0

4 years ago

0.108.0

4 years ago

0.107.0

4 years ago

0.106.1

4 years ago

0.106.0

4 years ago

0.105.0

4 years ago

0.104.0

4 years ago

0.103.0

4 years ago

0.102.4

4 years ago

0.102.3

4 years ago

0.102.1

4 years ago

0.102.0

4 years ago