-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Sagas running multiple times and socket closing
- Loading branch information
Lucas Leblow
committed
May 6, 2024
1 parent
0bd0d1a
commit 7f61ba6
Showing
18 changed files
with
302 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 14 additions & 6 deletions
20
packages/mobile/src/store/nativeServices/nativeServices.master.saga.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
import { all, fork, takeEvery } from 'typed-redux-saga' | ||
import { all, fork, takeEvery, cancelled } from 'typed-redux-saga' | ||
import { nativeServicesCallbacksSaga } from './events/nativeServicesCallbacks' | ||
import { leaveCommunitySaga } from './leaveCommunity/leaveCommunity.saga' | ||
import { flushPersistorSaga } from './flushPersistor/flushPersistor.saga' | ||
import { nativeServicesActions } from './nativeServices.slice' | ||
|
||
export function* nativeServicesMasterSaga(): Generator { | ||
yield all([ | ||
fork(nativeServicesCallbacksSaga), | ||
takeEvery(nativeServicesActions.leaveCommunity.type, leaveCommunitySaga), | ||
takeEvery(nativeServicesActions.flushPersistor.type, flushPersistorSaga), | ||
]) | ||
console.log('nativeServicesMasterSaga starting') | ||
try { | ||
yield all([ | ||
fork(nativeServicesCallbacksSaga), | ||
takeEvery(nativeServicesActions.leaveCommunity.type, leaveCommunitySaga), | ||
takeEvery(nativeServicesActions.flushPersistor.type, flushPersistorSaga), | ||
]) | ||
} finally { | ||
console.log('nativeServicesMasterSaga stopping') | ||
if (yield cancelled()) { | ||
console.log('nativeServicesMasterSaga cancelled') | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
import { Socket } from '../../types' | ||
import { all, takeEvery, takeLeading } from 'typed-redux-saga' | ||
import { all, takeEvery, takeLeading, cancelled } from 'typed-redux-saga' | ||
import { appActions } from './app.slice' | ||
import { closeServicesSaga } from './closeServices.saga' | ||
import { stopBackendSaga } from './stopBackend/stopBackend.saga' | ||
import { loadMigrationDataSaga } from './loadMigrationData/loadMigrationData.saga' | ||
|
||
export function* appMasterSaga(socket: Socket): Generator { | ||
yield* all([ | ||
takeLeading(appActions.closeServices.type, closeServicesSaga, socket), | ||
takeEvery(appActions.stopBackend.type, stopBackendSaga, socket), | ||
takeEvery(appActions.loadMigrationData.type, loadMigrationDataSaga, socket), | ||
]) | ||
console.log('appMasterSaga starting') | ||
try { | ||
yield* all([ | ||
takeLeading(appActions.closeServices.type, closeServicesSaga, socket), | ||
takeEvery(appActions.stopBackend.type, stopBackendSaga, socket), | ||
takeEvery(appActions.loadMigrationData.type, loadMigrationDataSaga, socket), | ||
]) | ||
} finally { | ||
console.log('appMasterSaga stopping') | ||
if (yield cancelled()) { | ||
console.log('appMasterSaga cancelled') | ||
} | ||
} | ||
} |
12 changes: 10 additions & 2 deletions
12
packages/state-manager/src/sagas/appConnection/connection.master.saga.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
import { all, fork } from 'typed-redux-saga' | ||
import { all, fork, cancelled } from 'typed-redux-saga' | ||
import { uptimeSaga } from './uptime/uptime.saga' | ||
|
||
export function* connectionMasterSaga(): Generator { | ||
yield all([fork(uptimeSaga)]) | ||
console.log('connectionMasterSaga starting') | ||
try { | ||
yield all([fork(uptimeSaga)]) | ||
} finally { | ||
console.log('connectionMasterSaga stopping') | ||
if (yield cancelled()) { | ||
console.log('connectionMasterSaga cancelled') | ||
} | ||
} | ||
} |
22 changes: 15 additions & 7 deletions
22
packages/state-manager/src/sagas/communities/communities.master.saga.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
import { type Socket } from '../../types' | ||
import { all, takeEvery } from 'typed-redux-saga' | ||
import { all, takeEvery, cancelled } from 'typed-redux-saga' | ||
import { communitiesActions } from './communities.slice' | ||
import { connectionActions } from '../appConnection/connection.slice' | ||
import { createCommunitySaga } from './createCommunity/createCommunity.saga' | ||
import { initCommunities, launchCommunitySaga } from './launchCommunity/launchCommunity.saga' | ||
import { createNetworkSaga } from './createNetwork/createNetwork.saga' | ||
|
||
export function* communitiesMasterSaga(socket: Socket): Generator { | ||
yield all([ | ||
takeEvery(communitiesActions.createNetwork.type, createNetworkSaga, socket), | ||
takeEvery(connectionActions.torBootstrapped.type, initCommunities), | ||
takeEvery(communitiesActions.createCommunity.type, createCommunitySaga, socket), | ||
takeEvery(communitiesActions.launchCommunity.type, launchCommunitySaga, socket), | ||
]) | ||
console.log('communitiesMasterSaga starting') | ||
try { | ||
yield all([ | ||
takeEvery(communitiesActions.createNetwork.type, createNetworkSaga, socket), | ||
takeEvery(connectionActions.torBootstrapped.type, initCommunities), | ||
takeEvery(communitiesActions.createCommunity.type, createCommunitySaga, socket), | ||
takeEvery(communitiesActions.launchCommunity.type, launchCommunitySaga, socket), | ||
]) | ||
} finally { | ||
console.log('communitiesMasterSaga stopping') | ||
if (yield cancelled()) { | ||
console.log('communitiesMasterSaga cancelled') | ||
} | ||
} | ||
} |
Oops, something went wrong.