Skip to content
This repository has been archived by the owner on Mar 8, 2018. It is now read-only.

Commit

Permalink
better doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Westby committed Jul 24, 2016
1 parent e76e381 commit 9c0785d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Start Elm apps without views

### Example

```elm
port module Main exposing (..)

Expand Down Expand Up @@ -44,7 +46,8 @@ main =
}
```

```js

```javascript
var app = Elm.Main.worker()
app.ports.modelOut.subscribe(function (model) {
document.getElementById('seconds').innerHTML = model.toString()
Expand Down
2 changes: 1 addition & 1 deletion elm-package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.0",
"version": "1.0.1",
"summary": "Start Elm applications without a view",
"repository": "https://github.com/lukewestby/worker.git",
"license": "MIT",
Expand Down
45 changes: 39 additions & 6 deletions src/Worker.elm
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,28 @@ wrapInit extraCmds innerInit =
)


{-| Start a worker program with flags from the outside world
{-| Start a worker program with flags from the outside world, including extra
Cmds to wrap init and update in case you want to include port calls on every
Msg.
```javascript
// Program { userId : String, token : String }
In your Elm program
port modelOut : Model -> Cmd msg
main : Program { userId: String, token : String }
main =
Worker.workerWithFlags modelOut
{ init = \{ userId, token } -> init userId token
, update = update
, subscriptions = subscriptions
}
In JavaScript
var app = Elm.MyApp.worker({
userId: 'Tom',
token: '12345'
});
```
-}
workerWithFlags :
(model -> Cmd msg)
Expand All @@ -65,7 +77,18 @@ workerWithFlags extraCmds { init, update, subscriptions } =
}


{-| Start a worker program
{-| Start a worker program, including extra Cmds to wrap init and update in case
you want to include port calls on every Msg.
port modelOut : Model -> Cmd msg
main : Program Never
main =
Worker.worker modelOut
{ init = init
, update = update
, subscriptions = subscriptions
}
-}
worker :
(model -> Cmd msg)
Expand All @@ -82,7 +105,17 @@ worker extraCmds { init, update, subscriptions } =
}


{-| Start a worker program with just a model a simpler update function
{-| Start a worker program with just a model and a simpler update function
port modelOut : Model -> Cmd msg
main : Program Never
main =
Worker.beginnerWorker modelOut
{ model = model
, update = update
}
-}
beginnerWorker :
(model -> Cmd msg)
Expand Down

0 comments on commit 9c0785d

Please sign in to comment.