Skip to content

Commit

Permalink
Use takeEvery
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Jan 13, 2019
1 parent 24e8d3d commit 1747e45
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
call,
put,
takeLatest
takeEvery
} from 'redux-saga/effects';

import deleteActivity from '../actions/deleteActivity';
Expand All @@ -12,7 +12,7 @@ function sleep(ms) {
}

export default function* () {
yield takeLatest(
yield takeEvery(
({ type, payload }) => (
type === INCOMING_ACTIVITY
&& payload.activity.type === 'typing'
Expand All @@ -22,6 +22,9 @@ export default function* () {
}

function* removeActivityAfterInterval({ payload: { activity: { id } } }) {
// TODO: [P2] We could optimize here.
// Given there is an activity typing activity, when the bot send another typing activity, we will remove the first one.
// That means, we don't actually need to remove it anymore, and could cancel out this call.
yield call(sleep, 5000);
yield put(deleteActivity(id));
}

0 comments on commit 1747e45

Please sign in to comment.