doc fixes
This commit is contained in:
parent
96ca6379d0
commit
d40b324645
6 changed files with 42 additions and 46 deletions
|
|
@ -45,19 +45,19 @@ m.route(document.body, "/home", {
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
#### m.route.set(path) - [docs](route.md#routeset)
|
#### m.route.set(path) - [docs](route.md#mrouteset)
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
m.route.set("/home")
|
m.route.set("/home")
|
||||||
```
|
```
|
||||||
|
|
||||||
#### m.route.get() - [docs](route.md#routeget)
|
#### m.route.get() - [docs](route.md#mrouteget)
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var currentRoute = m.route.get()
|
var currentRoute = m.route.get()
|
||||||
```
|
```
|
||||||
|
|
||||||
#### m.route.prefix(prefix) - [docs](route.md#routeprefix)
|
#### m.route.prefix(prefix) - [docs](route.md#mrouteprefix)
|
||||||
|
|
||||||
Call this before `m.route()`
|
Call this before `m.route()`
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ Call this before `m.route()`
|
||||||
m.route.prefix("#!")
|
m.route.prefix("#!")
|
||||||
```
|
```
|
||||||
|
|
||||||
#### m.route.link() - [docs](route.md#routelink)
|
#### m.route.link() - [docs](route.md#mroutelink)
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
m("a[href='/Home']", {oncreate: m.route.link}, "Go to home page")
|
m("a[href='/Home']", {oncreate: m.route.link}, "Go to home page")
|
||||||
|
|
@ -171,4 +171,3 @@ var Counter = {
|
||||||
|
|
||||||
m.mount(document.body, Counter)
|
m.mount(document.body, Counter)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ m.request("/api/v1/users", {background: true}).then(function() {
|
||||||
|
|
||||||
### After route changes
|
### After route changes
|
||||||
|
|
||||||
Mithril automatically redraws after [`m.route.set()`](route.md#routeset) calls (or route changes via links that use [`m.route.link`](route.md#routelink)
|
Mithril automatically redraws after [`m.route.set()`](route.md#mrouteset) calls (or route changes via links that use [`m.route.link`](route.md#mroutelink)
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var RoutedComponent = {
|
var RoutedComponent = {
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
- [Description](#description)
|
- [Description](#description)
|
||||||
- [Signature](#signature)
|
- [Signature](#signature)
|
||||||
- [Static members](#static-members)
|
- [Static members](#static-members)
|
||||||
- [route.set](#routeset)
|
- [m.route.set](#mrouteset)
|
||||||
- [route.get](#routeget)
|
- [m.route.get](#mrouteget)
|
||||||
- [route.prefix](#routeprefix)
|
- [m.route.prefix](#mrouteprefix)
|
||||||
- [route.link](#routelink)
|
- [m.route.link](#mroutelink)
|
||||||
- [RouteResolver](#routeresolver)
|
- [RouteResolver](#routeresolver)
|
||||||
- [routeResolver.onmatch](#routeresolveronmatch)
|
- [routeResolver.onmatch](#routeresolveronmatch)
|
||||||
- [routeResolver.render](#routeresolverrender)
|
- [routeResolver.render](#routeresolverrender)
|
||||||
|
|
@ -62,7 +62,7 @@ Argument | Type | Required | D
|
||||||
|
|
||||||
#### Static members
|
#### Static members
|
||||||
|
|
||||||
##### route.set
|
##### m.route.set
|
||||||
|
|
||||||
Redirects to a matching route, or to the default route if no matching routes can be found.
|
Redirects to a matching route, or to the default route if no matching routes can be found.
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ Argument | Type | Required | Description
|
||||||
`options.title` | `String` | No | The `title` string to pass to the underlying `history.pushState` / `history.replaceState` call.
|
`options.title` | `String` | No | The `title` string to pass to the underlying `history.pushState` / `history.replaceState` call.
|
||||||
**returns** | | | Returns `undefined`
|
**returns** | | | Returns `undefined`
|
||||||
|
|
||||||
##### route.get
|
##### m.route.get
|
||||||
|
|
||||||
Returns the last fully resolved routing path, without the prefix. It may differ from the path displayed in the location bar while an asynchronous route is [pending resolution](#code-splitting).
|
Returns the last fully resolved routing path, without the prefix. It may differ from the path displayed in the location bar while an asynchronous route is [pending resolution](#code-splitting).
|
||||||
|
|
||||||
|
|
@ -87,7 +87,7 @@ Argument | Type | Required | Description
|
||||||
----------------- | --------- | -------- | ---
|
----------------- | --------- | -------- | ---
|
||||||
**returns** | String | | Returns the last fully resolved path
|
**returns** | String | | Returns the last fully resolved path
|
||||||
|
|
||||||
##### route.prefix
|
##### m.route.prefix
|
||||||
|
|
||||||
Defines a router prefix. The router prefix is a fragment of the URL that dictates the underlying [strategy](routing-strategies.md) used by the router.
|
Defines a router prefix. The router prefix is a fragment of the URL that dictates the underlying [strategy](routing-strategies.md) used by the router.
|
||||||
|
|
||||||
|
|
@ -98,7 +98,7 @@ Argument | Type | Required | Description
|
||||||
`prefix` | `String` | Yes | The prefix that controls the underlying [routing strategy](#routing-strategy) used by Mithril.
|
`prefix` | `String` | Yes | The prefix that controls the underlying [routing strategy](#routing-strategy) used by Mithril.
|
||||||
**returns** | | | Returns `undefined`
|
**returns** | | | Returns `undefined`
|
||||||
|
|
||||||
##### route.link
|
##### m.route.link
|
||||||
|
|
||||||
`eventHandler = m.route.link(vnode)`
|
`eventHandler = m.route.link(vnode)`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,7 @@ The `m.route` call specifies that the application will be rendered into `documen
|
||||||
|
|
||||||
Refreshing the page in the browser should now append `#!/list` to the URL to indicate that routing is working. Since that route render UserList, we should still see the list of people on screen as before.
|
Refreshing the page in the browser should now append `#!/list` to the URL to indicate that routing is working. Since that route render UserList, we should still see the list of people on screen as before.
|
||||||
|
|
||||||
The `#!` snippet is known as a hashbang, and it's a commonly used string for implementing client-side routing. It's possible to configure this string it via [`m.route.prefix`](route.md#routeprefix). Some configurations require supporting server-side changes, so we'll just continue using the hashbang for the rest of this tutorial.
|
The `#!` snippet is known as a hashbang, and it's a commonly used string for implementing client-side routing. It's possible to configure this string it via [`m.route.prefix`](route.md#mrouteprefix). Some configurations require supporting server-side changes, so we'll just continue using the hashbang for the rest of this tutorial.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
- [Description](#description)
|
- [Description](#description)
|
||||||
- [Signature](#signature)
|
- [Signature](#signature)
|
||||||
- [Static members](#static-members)
|
- [Static members](#static-members)
|
||||||
- [stream.combine](#streamcombine)
|
- [Stream.combine](#streamcombine)
|
||||||
- [stream.merge](#streammerge)
|
- [Stream.merge](#streammerge)
|
||||||
- [stream.HALT](#streamhalt)
|
- [Stream.HALT](#streamhalt)
|
||||||
- [stream["fantasy-land/of"]](#streamfantasy-landof)
|
- [Stream["fantasy-land/of"]](#streamfantasy-landof)
|
||||||
- [Instance members](#static-members)
|
- [Instance members](#static-members)
|
||||||
- [stream.map](#streammap)
|
- [stream.map](#streammap)
|
||||||
- [stream.end](#streamend)
|
- [stream.end](#streamend)
|
||||||
|
|
@ -34,6 +34,12 @@ For example, in a spreadsheet, if `A1 = B1 + C1`, then changing the value of `B1
|
||||||
|
|
||||||
Similarly, you can make a stream depend on other streams so that changing the value of one automatically updates the other. This is useful when you have very expensive computations and want to only run them when necessary, as opposed to, say, on every redraw.
|
Similarly, you can make a stream depend on other streams so that changing the value of one automatically updates the other. This is useful when you have very expensive computations and want to only run them when necessary, as opposed to, say, on every redraw.
|
||||||
|
|
||||||
|
Streams are NOT bundled with Mithril's core distribution. To include the Streams module, use:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var Stream = require("mithril/stream")
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Signature
|
### Signature
|
||||||
|
|
@ -53,7 +59,7 @@ Argument | Type | Required | Description
|
||||||
|
|
||||||
#### Static members
|
#### Static members
|
||||||
|
|
||||||
##### stream.combine
|
##### Stream.combine
|
||||||
|
|
||||||
Creates a computed stream that reactively updates if any of its upstreams are updated. See [combining streams](#combining-streams)
|
Creates a computed stream that reactively updates if any of its upstreams are updated. See [combining streams](#combining-streams)
|
||||||
|
|
||||||
|
|
@ -85,7 +91,7 @@ Argument | Type | Required | Description
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
##### stream.merge
|
##### Stream.merge
|
||||||
|
|
||||||
Creates a stream whose value is the array of values from an array of streams
|
Creates a stream whose value is the array of values from an array of streams
|
||||||
|
|
||||||
|
|
@ -100,13 +106,13 @@ Argument | Type | Required | Description
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
##### stream.HALT
|
##### Stream.HALT
|
||||||
|
|
||||||
A special value that can be returned to stream callbacks to halt execution of downstreams
|
A special value that can be returned to stream callbacks to halt execution of downstreams
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
##### stream["fantasy-land/of"]
|
##### Stream["fantasy-land/of"]
|
||||||
|
|
||||||
This method is functionally identical to `stream`. It exists to conform to [Fantasy Land's Applicative specification](https://github.com/fantasyland/fantasy-land). For more information, see the [What is Fantasy Land](#what-is-fantasy-land) section.
|
This method is functionally identical to `stream`. It exists to conform to [Fantasy Land's Applicative specification](https://github.com/fantasyland/fantasy-land). For more information, see the [What is Fantasy Land](#what-is-fantasy-land) section.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -278,28 +278,19 @@ ospec will automatically evaluate all `*.js` files in any folder named `/tests`.
|
||||||
$ npm test
|
$ npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
#### (Optionally) Install Globally
|
#### Installing ospec globally
|
||||||
|
|
||||||
|
While it's recommended to install ospec locally to maintain reproducible environments, sometimes it may be deemed appropriate to install it globally. To do so, run this command:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ npm i -g ospec
|
npm install ospec -g
|
||||||
$ ospec
|
|
||||||
```
|
|
||||||
|
|
||||||
#### (Optionally) Evaluate ES6+ code:
|
|
||||||
|
|
||||||
One way to accomplish this would be to include the 'babel-cli' module (`npm i babel-cli`)
|
|
||||||
|
|
||||||
(This would pre-suppose that you're already using babel in your project and thus have it configured to your liking).
|
|
||||||
|
|
||||||
```
|
|
||||||
$ babel-node ospec
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
*Square brackets denote optional arguments
|
Square brackets denote optional arguments
|
||||||
|
|
||||||
### void o.spec(String title, Function tests)
|
### void o.spec(String title, Function tests)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue