File tree Expand file tree Collapse file tree 5 files changed +13
-7
lines changed Expand file tree Collapse file tree 5 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { Provider } from 'react-redux';
44import { WorkflowManager , WorkflowManagerConfig } from '../../../dist' ;
55import { Child } from './Child' ;
66import { store } from './store' ;
7+ import { createClientId } from './utils' ;
78
89WorkflowManagerConfig . setStore ( store ) ;
910
@@ -13,7 +14,7 @@ export const Basic: React.FC = () => {
1314 < WorkflowManager
1415 brokerUrl = "ws://broker.mqttdashboard.com:8000/mqtt"
1516 options = { {
16- clientId : `clientId- ${ Math . random ( ) . toString ( 36 ) . substring ( 2 , 9 ) } ` ,
17+ clientId : createClientId ( ) ,
1718 keepalive : 60 ,
1819 } }
1920 >
Original file line number Diff line number Diff line change 1+ export const createClientId = ( ) => {
2+ const array = new Uint8Array ( 20 ) ;
3+
4+ window . crypto . getRandomValues ( array ) ;
5+
6+ return Array . from ( array , ( dec ) =>
7+ ( '0' + dec . toString ( 16 ) ) . substring ( - 2 ) ,
8+ ) . join ( '' ) ;
9+ } ;
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ class WorkflowManagerConfig implements WorkflowManagerConfigProps {
9595 const client = this . getMqttClient ( ) ;
9696 const store = WorkflowManagerConfig . _store ;
9797
98- const shouldSubscribe = shouldSubscribeOrUnsubscribe ( topic , store , client ) ;
98+ const shouldSubscribe = shouldSubscribeOrUnsubscribe ( store , client ) ;
9999
100100 if ( ! shouldSubscribe ) return ;
101101
@@ -126,7 +126,7 @@ class WorkflowManagerConfig implements WorkflowManagerConfigProps {
126126 const client = this . getMqttClient ( ) ;
127127 const store = WorkflowManagerConfig . _store ;
128128
129- const unsubscribe = shouldSubscribeOrUnsubscribe ( topic , store , client ) ;
129+ const unsubscribe = shouldSubscribeOrUnsubscribe ( store , client ) ;
130130
131131 if ( ! unsubscribe ) return ;
132132
Original file line number Diff line number Diff line change 1- export const VALID_TOPIC_PATTERN =
2- / ^ ( ( [ \\ + # ] { 1 } | [ ^ \\ + # ] * ) \/ ) ? ( ( [ \\ + # ] { 1 } | [ ^ \\ + # ] * ) \/ { 1 } ) * ( ( [ \\ + # ] { 1 } | [ ^ \\ + # ] * ) ) $ / ;
3-
41export const ERROR_MESSAGES = {
52 NO_WRAPPER :
63 'No context found. Did you forget to wrap your app with WorkflowManager component?' ,
Original file line number Diff line number Diff line change 11export * from './constants.util' ;
2- export * from './isValidTopic.util' ;
32export * from './isValidJSON.util' ;
43export * from './shouldSubscribeOrUnsubscribe.util' ;
You can’t perform that action at this time.
0 commit comments