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
// 1 | |
let process = function*() { | |
while(true) { | |
console.log("Process loop.") | |
yield delay(1000) | |
} | |
} | |
// 2 | |
let saga = function*() { |
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
import { | |
call, | |
take | |
} from 'redux-saga' | |
import { reducer } from '../../Reducer/index' | |
import * as ChatActions from "../../Actions"; | |
// dummy data | |
const previousState = { |
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
// 1 | |
function* fn() { | |
while(true) { | |
console.info('FN!'); | |
yield delay(1000); | |
} | |
} | |
// 2 | |
let forkSaga = function*() { |
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
// 1 | |
let fn = () => { | |
console.log('Called the function!!') | |
} | |
// 2 | |
let callSaga = function*() { | |
yield fn(); | |
} |
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
// 1 | |
let mySaga = function*() { | |
console.info('Saga begins!!'); | |
const state = yield effects.take('SET_STATE'); | |
console.info('Got state...', state); | |
} | |
// 2 | |
run(mySaga); |
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
// run in the console of sandbox | |
// 1 | |
effects.take('MY_ACTION'); | |
// 2 | |
let mySaga = function*() { | |
console.info('Saga begins!!'); | |
const state = yield effects.take('SET_STATE'); | |
console.info('Got state...', state); |
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
// create a generator function | |
let generator = function*() { | |
return 5 | |
} | |
let obj = generator() | |
obj.generator().next() | |
// iterate throught it | |
generator = function*() { | |
yield 1; |
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
// jestdescr | |
// Inserts describe() block | |
describe('$NAME$', function() { | |
$END$ | |
}); |
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
// open the dev environment | |
// https://stephengrider.github.io/JSPlaygrounds/ | |
// create reducer (function) | |
const reducer = (state = [], action) => { | |
if (action.type === 'SPLIT_STRING') { | |
return action.payload.split(''); | |
} else if (action.type === 'ADD_CARACTER') { | |
// DO NOT MUTATE DATA IN A REDUCER | |
//state.push(action.payload); |
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
#!/bin/bash | |
# install wget, virtualbox and vagrant | |
brew install wget | |
# enable in mac preferences to run oracle vm: https://developer.apple.com/library/content/technotes/tn2459/_index.html | |
brew cask install --force virtualbox | |
brew cask install vagrant | |
brew cask install vagrant-manager | |
# get a fresh Ubuntu 14.04 machine running and create a Vagrantfile |