Last active
October 22, 2018 15:21
-
-
Save OtavioBraga/c9c8e8c8ab51605ccddb5cadee5f88b4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export function * watchMessages (eventChannel) { | |
// Executamos indefinidamente | |
while (true) { | |
// Usamos o effect take para ler os eventos do channel | |
const event = yield take(eventChannel) | |
// Enviamos uma ação para nossa store do redux | |
yield put({ type: WS_NEW_EVENT, payload: JSON.parse(event) }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment