Skip to content

Instantly share code, notes, and snippets.

Avatar

Gael du Plessix gaelduplessix

View GitHub Profile
@gaelduplessix
gaelduplessix / sagas-example.js
Created Oct 24, 2016
Examples of Snapshot testing a Redux Saga
View sagas-example.js
/**
* Basic saga that revokes session and redirects to /login
* each time a LOGOUT action is dispatched
*/
function* logoutSaga() {
while (true) {
yield take(LOGOUT)
yield put(revokeSession())
yield put(redirect('/login'))
}
@gaelduplessix
gaelduplessix / ControlledRouter.js
Last active Oct 6, 2016 — forked from steida/Root.jsx
React Router v4 ControlledRouter
View ControlledRouter.js
// @flow
import React, { Component } from 'react'
import BrowserHistory from 'react-history/BrowserHistory'
import { Push } from 'react-history'
import { StaticRouter } from 'react-router'
/**
* ControlledRouter, greatly inspired by https://gist.github.com/donnanicolas/3d76397a92551f449637590bf0413133
@gaelduplessix
gaelduplessix / index.html
Created Jun 7, 2016
Track mouse position (useful for e2e debugging, for example)
View index.html
<div id="mouse" style="width:10px; height: 10px; background: red; position: absolute;"></div>
<script type="text/javascript">
setTimeout(function () {
var $ = jQuery;
$(document).mousemove(function (e) {
$('#mouse').css({ top: e.clientY + 1, left: e.clientX + 1});
});
}, 1000);
</script>