This file contains 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
var h = require('virtual-dom/h'); | |
var diff = require('virtual-dom/diff'); | |
var patch = require('virtual-dom/patch'); | |
var createElement = require('virtual-dom/create-element'); | |
// 1: Create a function that declares what the DOM should look like | |
function render(value) { | |
return h('input', { | |
className: "form-control", | |
type: "range", |
This file contains 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
var h = require('virtual-dom/h'); | |
var diff = require('virtual-dom/diff'); | |
var patch = require('virtual-dom/patch'); | |
var createElement = require('virtual-dom/create-element'); | |
// 1: Create a function that declares what the DOM should look like | |
function render(value) { | |
return h('input', { | |
attributes: { | |
class: "form-control", |
This file contains 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
// This doesn't work, it's just a draft while thinking how best to model collections of non-trivial objects | |
const model = (function () { | |
const mediaAsset$ = createStream(droppedFiles$.filter(droppedFile => droppedFile.type.match('image.*')) | |
.map (droppedfile => { | |
const reader = new FileReader(); | |
const asset = { | |
id = cuid(), | |
name = droppedfile.name, | |
imageLoadSucceeded$ = Rx.Observable.fromEvent(reader.onload).map(_ => reader.result), |
This file contains 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 PortAction | |
= StartAudioPlayback AudioPlaybackMessage | |
| StopAudioPlayback | |
| DecodeAudioData AudioRawDataMessage | |
| NoopPortAction | |
update : Action -> Model -> (Model, Effects Action, PortAction) | |
app : App Model MainActions.PortAction | |
app = |
This file contains 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
module CustomStartApp where | |
import Debug | |
import Html exposing (Html) | |
import Signal exposing (Address) | |
import Automaton exposing ((>>>)) | |
type alias Config model action = | |
{ model : model | |
, view : Address action -> model -> Html |
This file contains 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 Html exposing (div, button, text) | |
import Html.Events exposing (onClick) | |
import Signal exposing (Mailbox, mailbox, send) | |
import StartApp.Simple as StartApp | |
main = | |
StartApp.start { model = model, view = view, update = update } | |
model = "hi" |
This file contains 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
module PortsExample where | |
import Html exposing (div, button, text) | |
import Html.Events exposing (onClick) | |
import Signal exposing (Mailbox, mailbox, send) | |
import StartApp | |
import Effects | |
type alias Model = String |
This file contains 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
module CustomStartApp (start, App, Config) where | |
import Html exposing (Html) | |
import Effects exposing (Effects, Never) | |
import Task | |
type alias Config model action portAction = | |
{ init : ( model, Effects action, portAction ) | |
, update : action -> model -> ( model, Effects action, Maybe portAction ) |
This file contains 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
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
import System.Environment | |
import GHC.Generics | |
import Data.Aeson | |
import Data.Text (Text) | |
import Data.List (intersperse) |
This file contains 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
data MyMaybe a = | |
MyNothing | |
| MyJust a | |
deriving (Show) | |
instance Functor MyMaybe where | |
fmap _ MyNothing = MyNothing | |
fmap f (MyJust a) = MyJust (f a) | |
OlderNewer