Skip to content

Instantly share code, notes, and snippets.

View sophiebits's full-sized avatar

Sophie Alpert sophiebits

View GitHub Profile
@sophiebits
sophiebits / reducer-with-effects.js
Last active July 29, 2020 12:10 — forked from davidkpiano/reducer-with-effects.js
An idea for actor-model-based effects with reducers
import {
useReducerWithEffects,
emitEffect,
} from 'react';
// In a component
const UserComponent = () => {
function fetchUserEffect(id, parentRef) {
const controller = new AbortController();
<!doctype html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-shim.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-sham.js"></script>
<script src="http://fb.me/react-0.8.0.min.js"></script>
<script src="http://fb.me/JSXTransformer-0.8.0.js"></script>
<script type="text/jsx">
/** @jsx React.DOM */
var InputBox = React.createClass({
/* This class is used to create the /topic/projectfeedback page,
* which shows expandable lists of feedback requests that need answering.
*/
var ProjectFeedbackPage = React.createClass({
propTypes: {
topic: React.PropTypes.string.isRequired
},
render: function() {
var helpCollection = new DiscussionItemCollection([], {
topic: this.props.topic,
require "rack"
app = lambda do |env|
request = Rack::Request.new(env)
if request.get?
[
200,
{"Content-Type" => "text/html"},
<<-HTML