<html>
<head>
<script src="https://unpkg.com/react@15.2.1/dist/react.min.js"></script>
<script src="https://unpkg.com/react-dom@15.2.1/dist/react-dom.min.js"></script>
<script src="https://unpkg.com/redux@^3.5.2/dist/redux.min.js"></script>
<script src="https://unpkg.com/react-redux@4.4.5/dist/react-redux.min.js"></script>
<script src="https://unpkg.com/@reactivex/rxjs@5.0.0-rc.1/dist/global/Rx.js"></script>
<script src="https://unpkg.com/redux-observable/dist/redux-observable.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
/**
* IMPORTANT ***************************************************************
*
* This example uses the global version of RxJS that includes ALL operators.
* Inside your app, you will likely need to import the operators you use or
* import all of them in your index.js entry file.
*
* Learn more about this: http://goo.gl/4ZlYeC
*/
console.clear();
const { Observable } = Rx;
const { combineEpics } = ReduxObservable;
const a = {
INVITE_USER: 'INVITE_USER'
};
const authActions = {
REGISTER_REQ: 'REGISTER_REQ',
REGISTER_SUCCESS: 'REGISTER_SUCCESS'
};
const push = path => ({
type: 'PUSH',
path
});
const registerEpic = (action$) =>
action$.ofType(authActions.REGISTER_REQ)
.delay(500)
.map(() => ({
type: authActions.REGISTER_SUCCESS
}));
const inviteUserEpic = (action$) =>
action$.ofType(a.INVITE_USER)
.flatMap(({ body }) =>
Observable.concat(
Observable.of({ type: authActions.REGISTER_REQ, body }),
action$.ofType(authActions.REGISTER_SUCCESS)
.map(() => push(`/team/${body.teamId}`))
)
);
const rootEpic = combineEpics(registerEpic, inviteUserEpic);
const reducer = (state = [], action) => {
console.log(action);
return [
state,
action
];
};
const { connect } = ReactRedux;
let App = ({ inviteUser, actions }) => (
<div>
<button onClick={inviteUser}>Invite User</button>
<div>
<h4>Actions dispatched:</h4>
{actions.map(action =>
<p>{action.type}</p>
)}
</div>
</div>
);
App = connect(state => ({ actions: state }), dispatch => ({
inviteUser: () => dispatch({
type: a.INVITE_USER,
body: {
teamId: 123
}
})
}))(App);
// redux/configureStore.js
const { Provider } = ReactRedux;
const { createStore, applyMiddleware } = Redux;
const { createEpicMiddleware } = ReduxObservable;
const epicMiddleware = createEpicMiddleware(rootEpic);
const store = createStore(reducer,
applyMiddleware(epicMiddleware)
);
// index.js
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
);
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |