-
-
Save dinh/c147f43a088a4b99e82f531e1ad498cc to your computer and use it in GitHub Desktop.
Revisions
-
ssrdjan-fadv revised this gist
Jun 14, 2020 . 1 changed file with 45 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ import React from 'react'; import { hawk, hawkeye, useHawkState, useHawkSetState } from 'react-hawk'; const counterState = hawk({ key: 'counter', default: 0 }); const isEvenState = hawkeye({ key: 'isEven', get: ({ get }) => { const count = get(counterState) return Boolean(count % 2) ? 'odd' : 'even' } }) const useIncrease = () => { const setCounter = useHawkSetState(counterState) const increase = (n = 1) => { setCounter(count => count + n) } return increase } const useDecrease = () => { const setCounter = useHawkSetState(counterState) const decrease = (n = 1) => { setCounter(count => count - n) } return decrease } export const Counter = () => { const count = useHawkState(counterState) const even = useHawkState(isEvenState) const decrease = useDecrease() const increase = useIncrease() return ( <> <button onClick={() => decrease()}>-</button> {count} is {even} <button onClick={() => increase()}>+</button> </> ) } -
ssrdjan-fadv revised this gist
Jun 9, 2020 . 1 changed file with 12 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ import { createState } from "solid-js"; const Counter = () => { const [state, setState] = createState({ counter: 0 }); return <div> {state.counter} <button type="button" onClick={() => setState({ counter: state.counter + 1 }}>+1</button> <button type="button" onClick={() => setState({ counter: state.counter - 1 }}>-1</button> </div>; }; render(() => createComponent(Counter, document.getElementById("app")); -
ssrdjan-fadv revised this gist
Jun 7, 2020 . 2 changed files with 24 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { Provider, createAtom, useAtom } from 'use-atom'; const countAtom = createAtom({ default: 0 }); const Counter = () => { const [count, setCount] = useAtom(countAtom); return ( <div> <span>Count: {count}</span> <button type="button" onClick={() => setCount(count + 1)}>+1</button> <button type="button" onClick={() => setCount((c) => c - 1)}>-1</button> </div> ); }; const App = () => ( <Provider> <h1>Counter</h1> <Counter /> </Provider> ); -
ssrdjan-fadv renamed this gist
Jun 6, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ssrdjan-fadv renamed this gist
Jun 6, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ssrdjan-fadv revised this gist
Jun 6, 2020 . 106 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes.File renamed without changes. -
ssrdjan-fadv renamed this gist
Jun 6, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ssrdjan-fadv revised this gist
Jun 6, 2020 . 2 changed files with 22 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ module Main where import Prelude import Effect (Effect) import Concur.Core (Widget) import Concur.React (HTML) import Concur.React.DOM as D import Concur.React.Props as P import Concur.React.Run (runWidgetInDom) counterWidget :: forall a. Int -> Widget HTML a counterWidget count = do n <- D.div' [ D.p' [D.text ("State: " <> show count)] , D.button [P.onClick] [D.text "Increment"] $> count+1 , D.button [P.onClick] [D.text "Decrement"] $> count-1 ] counterWidget n main :: Effect Unit main = runWidgetInDom "main" (counterWidget 0) -
ssrdjan-fadv revised this gist
May 26, 2020 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ More than 100 different counter app implementations... -
ssrdjan-fadv revised this gist
May 26, 2020 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ -
ssrdjan-fadv revised this gist
May 26, 2020 . 2 changed files with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ ... using diff libraries and frameworks -
ssrdjan-fadv revised this gist
May 26, 2020 . 1 changed file with 30 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ import { wired, on, component } from "capsid"; @component("counter") export class Counter { count: number = 0; @wired(".label") label: HTMLElement; __mount__() { this.update(); } @on.click.at(".plus") plus() { this.count++; this.update(); } @on.click.at(".minus") minus() { this.count--; this.update(); } /** Updates the label. */ update() { this.label.textContent = `${this.count}`; } } -
ssrdjan-fadv revised this gist
May 22, 2020 . 1 changed file with 32 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ open Feliz open Feliz.UseElmish open Elmish type Msg = | Increment | Decrement type State = { Count : int } let init() = { Count = 0 }, Cmd.none let update msg state = match msg with | Increment -> { state with Count = state.Count + 1 }, Cmd.none | Decrement -> { state with Count = state.Count - 1 }, Cmd.none let counter = React.functionComponent(fun () -> let state, dispatch = React.useElmish(init, update, [| |]) Html.div [ Html.h1 state.Count Html.button [ prop.text "Increment" prop.onClick (fun _ -> dispatch Increment) ] Html.button [ prop.text "Decrement" prop.onClick (fun _ -> dispatch Decrement) ] ] ) -
ssrdjan-fadv revised this gist
May 15, 2020 . 2 changed files with 16 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ import React from "react"; import { StateLake } from "statelake"; const store = new StateLake({ count: ""}); export default function App() { const [count, setCount] = store.useState("count")(); return ( <div className="App"> <button onClick={() => setCount(count + 1)}>+</button> <button onClick={() => setCount(count - 1)}>-</button> <div>{count}</div> </div> ); } -
ssrdjan-fadv revised this gist
May 9, 2020 . 2 changed files with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ ... using many diff libraries and frameworks 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 charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ -
ssrdjan-fadv renamed this gist
May 9, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ssrdjan-fadv revised this gist
May 9, 2020 . 2 changed files with 46 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ import { define } from 'uce'; import { render, html } from 'uhtml'; define("my-counter", { init() { this.count = 0; this.dec = () => { this.count--; this.render(); }; this.inc = () => { this.count++; this.render(); }; this.render(); }, render() { this.html` <button onclick="${this.dec}">-</button> <span>${this.count}</span> <button onclick="${this.inc}">+</button> `; } }); addEventListener( 'DOMContentLoaded', () => { // populate the body render(document.body, html` <my-counter /> <footer></footer> `); // fetch project details and populate the footer fetch('package.json') .then(_ => _.json()) .then(({description, version}) => { render(document.querySelector('footer'), html` ${description} v${version} `); }); }, {once: true} ); -
ssrdjan-fadv renamed this gist
May 9, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ssrdjan-fadv renamed this gist
May 9, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ssrdjan-fadv revised this gist
May 9, 2020 . 3 changed files with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,4 +7,5 @@ const Counter = () => ( <span>{value}</span> <button onClick={() => decrement()}>-1</button> )} </NumberValue> ) 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ import React from 'react' export const init = count => count const Action = { File renamed without changes. -
ssrdjan-fadv revised this gist
May 9, 2020 . 2 changed files with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ ... using diff frameworks -
ssrdjan-fadv revised this gist
May 9, 2020 . 1 changed file with 32 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ module Examples.NoEffects.Counter.Main where import Prelude import Effect (Effect) import Flame (QuerySelector(..), Html) import Flame.Application.NoEffects as FAN import Flame.HTML.Element as HE import Flame.HTML.Attribute as HA type Model = Int data Message = Increment | Decrement init :: Model init = 0 update :: Model -> Message -> Model update model = case _ of Increment -> model + 1 Decrement -> model - 1 view :: Model -> Html Message view model = HE.main "main" [ HE.button [HA.onClick Decrement] "-", HE.text $ show model, HE.button [HA.onClick Increment] "+" ] main :: Effect Unit main = FAN.mount_ (QuerySelector "main") { init, update, view } -
ssrdjan-fadv revised this gist
May 5, 2020 . 1 changed file with 19 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ import { useStoreon } from 'storeon-solidjs' let counter = store => { store.on('@init', () => ({ count: 0 })) store.on('inc', ({ count }) => ({ count: count + 1 })) store.on('dec', ({ count }) => ({ count: count - 1 })) } export default function Counter() { const [state, dispatch] = useStoreon() return ( <div> {state.count} <button onClick={() => dispatch('inc')}>inc</button> <button onClick={() => dispatch('dec')}>dec</button> </div> ) } -
ssrdjan-fadv revised this gist
May 3, 2020 . 1 changed file with 18 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ import { render } from "preact"; import flowponent from "flowponent"; const App = flowponent(function*() { let count = 0; for (;;) { count += yield resolve => ( <div> <div>current value: {count}</div> <button onClick={() => resolve(1)}>+1</button> <button onClick={() => resolve(-1)}>-1</button> </div> ); } }); render(<App />, document.getElementById("root")); -
ssrdjan-fadv revised this gist
May 2, 2020 . 3 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes.File renamed without changes. -
ssrdjan-fadv renamed this gist
May 2, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ssrdjan-fadv revised this gist
May 2, 2020 . 1 changed file with 2 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,8 @@ <template> <div> <button @click="this.dec">-</button> <span>{{count}}</span> <button @click="this.inc">+</button> </div> </template> -
ssrdjan-fadv revised this gist
May 2, 2020 . 1 changed file with 0 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,14 @@ import { html } from 'hybrids'; import store, { increment, decrement } from './redux'; const connect = (store, mapState) => ({ get: mapState ? () => mapState(store.getState()) : () => store.getState(), connect: (host, key, invalidate) => store.subscribe(invalidate), }); const onInc = ({ offset }) => store.dispatch(increment(offset)); const onDec = ({ offset }) => store.dispatch(decrement(offset)); export default { count: connect(store, (state) => state.count), offset: 1, -
ssrdjan-fadv revised this gist
May 2, 2020 . No changes.There are no files selected for viewing
-
ssrdjan-fadv revised this gist
May 2, 2020 . No changes.There are no files selected for viewing
NewerOlder