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 React from "react"; | |
| function Counter({ n, inc, dec }) { | |
| return ( | |
| <Container> | |
| <Content>{n}</Content> | |
| <Buttons> | |
| <button onClick={dec}>-</button> | |
| <button onClick={inc}>+</button> | |
| </Buttons> |
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 React from "react"; | |
| import { initialize, split } from "apothecary"; | |
| import { Bridge, tunnel, fromProps } from "react-apothecary"; | |
| import { Container, Buttons, Content } from "./styles"; | |
| const store = initialize({ n: 1 }); | |
| const increment = step => split(n => n + step, "n"); | |
| const decrement = step => split(n => n - step, "n"); |
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
| extern crate serde_json; | |
| fn main() { | |
| println!("Hello, world!"); | |
| } |
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
| #[macro_use] | |
| extern crate serde_derive; | |
| extern crate serde; | |
| extern crate serde_json; | |
| use std::os::raw::{c_char}; | |
| use std::ffi::CString; |
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
| (function() { | |
| function copyCStr(module, ptr) { | |
| let orig_ptr = ptr; | |
| const collectCString = function* () { | |
| let memory = new Uint8Array(module.memory.buffer); | |
| while (memory[ptr] !== 0) { | |
| if (memory[ptr] === undefined) { throw new Error("Tried to read undef mem") } | |
| yield memory[ptr] | |
| ptr += 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
| function flatten(list = []) { | |
| const [head, ...tail] = list; | |
| if (!head) { | |
| return []; | |
| } | |
| if (Array.isArray(head)) { | |
| return flatten(head).concat(flatten(tail)); | |
| } |
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
| type parcelModule; | |
| type hot; | |
| [@bs.val] external parcelModule : parcelModule = "module"; | |
| [@bs.get] external hot : parcelModule => Js.nullable(hot) = "hot"; | |
| [@bs.send.pipe : hot] external accept : unit => unit = "accept"; |
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
| { | |
| "name": "sparcely-unreasonable", | |
| "version": "0.1.0", | |
| "sources": { | |
| "dir": "src", | |
| "subdirs": true | |
| }, | |
| "bs-dependencies": ["reason-react"], | |
| "reason": { | |
| "react-jsx": 2 |
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
| let component = ReasonReact.statelessComponent("App"); | |
| let make = (_) => { | |
| ...component, | |
| render: _ => <h1> (ReasonReact.string("Hello Worldy")) </h1> | |
| } |
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
| ReactDOMRe.renderToElementWithId(<App />, "root"); | |
| type parcelModule; | |
| type hot; | |
| [@bs.val] external parcelModule : parcelModule = "module"; | |
| [@bs.get] external hot : parcelModule => Js.nullable(hot) = "hot"; | |
| [@bs.send.pipe : hot] external accept : unit => unit = "accept"; | |
| switch (Js.Nullable.toOption(parcelModule |> hot)) { | |
| | Some(h) => h |> accept() |