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
|
||||
m.route.set("/home")
|
||||
```
|
||||
|
||||
#### m.route.get() - [docs](route.md#routeget)
|
||||
#### m.route.get() - [docs](route.md#mrouteget)
|
||||
|
||||
```javascript
|
||||
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()`
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ Call this before `m.route()`
|
|||
m.route.prefix("#!")
|
||||
```
|
||||
|
||||
#### m.route.link() - [docs](route.md#routelink)
|
||||
#### m.route.link() - [docs](route.md#mroutelink)
|
||||
|
||||
```javascript
|
||||
m("a[href='/Home']", {oncreate: m.route.link}, "Go to home page")
|
||||
|
|
@ -171,4 +171,3 @@ var Counter = {
|
|||
|
||||
m.mount(document.body, Counter)
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ m.request("/api/v1/users", {background: true}).then(function() {
|
|||
|
||||
### 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
|
||||
var RoutedComponent = {
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
- [Description](#description)
|
||||
- [Signature](#signature)
|
||||
- [Static members](#static-members)
|
||||
- [route.set](#routeset)
|
||||
- [route.get](#routeget)
|
||||
- [route.prefix](#routeprefix)
|
||||
- [route.link](#routelink)
|
||||
- [m.route.set](#mrouteset)
|
||||
- [m.route.get](#mrouteget)
|
||||
- [m.route.prefix](#mrouteprefix)
|
||||
- [m.route.link](#mroutelink)
|
||||
- [RouteResolver](#routeresolver)
|
||||
- [routeResolver.onmatch](#routeresolveronmatch)
|
||||
- [routeResolver.render](#routeresolverrender)
|
||||
|
|
@ -62,7 +62,7 @@ Argument | Type | Required | D
|
|||
|
||||
#### Static members
|
||||
|
||||
##### route.set
|
||||
##### m.route.set
|
||||
|
||||
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.
|
||||
**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).
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ Argument | Type | Required | Description
|
|||
----------------- | --------- | -------- | ---
|
||||
**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.
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ Argument | Type | Required | Description
|
|||
`prefix` | `String` | Yes | The prefix that controls the underlying [routing strategy](#routing-strategy) used by Mithril.
|
||||
**returns** | | | Returns `undefined`
|
||||
|
||||
##### route.link
|
||||
##### m.route.link
|
||||
|
||||
`eventHandler = m.route.link(vnode)`
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ The `render` method is called on every redraw for a matching route. It is simila
|
|||
`vnode = routeResolve.render(vnode)`
|
||||
|
||||
Argument | Type | Description
|
||||
------------------- | --------------- | -----------
|
||||
------------------- | --------------- | -----------
|
||||
`vnode` | `Object` | A [vnode](vnodes.md) whose attributes object contains routing parameters. If onmatch does not return a component or a promise that resolves to a component, the vnode's `tag` field defaults to `"div"`
|
||||
`vnode.attrs` | `Object` | A map of URL parameter values
|
||||
**returns** | `Vnode` | Returns a vnode
|
||||
|
|
@ -304,7 +304,7 @@ var state = {
|
|||
// save the state for this route
|
||||
// this is equivalent to `history.replaceState({term: state.term}, null, location.href)`
|
||||
m.route.set(m.route.get(), null, {replace: true, state: {term: state.term}})
|
||||
|
||||
|
||||
// navigate away
|
||||
location.href = "https://google.com/?q=" + state.term
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -385,7 +385,7 @@ var User = {
|
|||
User.list = result.data
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
current: {},
|
||||
load: function(id) {
|
||||
return m.request({
|
||||
|
|
@ -498,7 +498,7 @@ var User = {
|
|||
User.list = result.data
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
current: {},
|
||||
load: function(id) {
|
||||
return m.request({
|
||||
|
|
@ -511,7 +511,7 @@ var User = {
|
|||
User.current = result
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
save: function() {
|
||||
return m.request({
|
||||
method: "PUT",
|
||||
|
|
@ -602,4 +602,4 @@ In the `/edit/:id` route, there's also a `vnode` argument that carries the route
|
|||
|
||||
Refresh the page in the browser and now you'll see the global navigation on every page in the app.
|
||||
|
||||
---
|
||||
---
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
- [Description](#description)
|
||||
- [Signature](#signature)
|
||||
- [Static members](#static-members)
|
||||
- [stream.combine](#streamcombine)
|
||||
- [stream.merge](#streammerge)
|
||||
- [stream.HALT](#streamhalt)
|
||||
- [stream["fantasy-land/of"]](#streamfantasy-landof)
|
||||
- [Stream.combine](#streamcombine)
|
||||
- [Stream.merge](#streammerge)
|
||||
- [Stream.HALT](#streamhalt)
|
||||
- [Stream["fantasy-land/of"]](#streamfantasy-landof)
|
||||
- [Instance members](#static-members)
|
||||
- [stream.map](#streammap)
|
||||
- [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.
|
||||
|
||||
Streams are NOT bundled with Mithril's core distribution. To include the Streams module, use:
|
||||
|
||||
```javascript
|
||||
var Stream = require("mithril/stream")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Signature
|
||||
|
|
@ -53,7 +59,7 @@ Argument | Type | Required | Description
|
|||
|
||||
#### 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)
|
||||
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -94,19 +100,19 @@ Creates a stream whose value is the array of values from an array of streams
|
|||
Argument | Type | Required | Description
|
||||
------------ | -------------------- | -------- | ---
|
||||
`streams` | `Array<Stream>` | Yes | A list of streams
|
||||
**returns** | `Stream` | | Returns a stream whose value is an array of input stream values
|
||||
**returns** | `Stream` | | Returns a stream whose value is an array of input stream values
|
||||
|
||||
[How to read signatures](signatures.md)
|
||||
|
||||
---
|
||||
|
||||
##### stream.HALT
|
||||
##### Stream.HALT
|
||||
|
||||
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.
|
||||
|
||||
|
|
@ -498,4 +504,4 @@ Now this method works with any Fantasy Land compliant [Functor](https://github.c
|
|||
|
||||
This example may seem convoluted, but it's a trade-off in complexity: the naive `plusOne` implementation makes sense if you have a simple system and only ever increment numbers, but the Fantasy Land implementation becomes more powerful if you have a large system with many wrapper abstractions and reused algorithms.
|
||||
|
||||
When deciding whether you should adopt Fantasy Land, you should consider your team's familiarity with functional programming, and be realistic regarding the level of discipline that your team can commit to maintaining code quality (vs the pressure of writing new features and meeting deadlines). Functional style programming heavily depends on compiling, curating and mastering a large set of small, precisely defined functions, and therefore it's not suitable for teams who do not have solid documentation practices, and/or lack experience in functional oriented languages.
|
||||
When deciding whether you should adopt Fantasy Land, you should consider your team's familiarity with functional programming, and be realistic regarding the level of discipline that your team can commit to maintaining code quality (vs the pressure of writing new features and meeting deadlines). Functional style programming heavily depends on compiling, curating and mastering a large set of small, precisely defined functions, and therefore it's not suitable for teams who do not have solid documentation practices, and/or lack experience in functional oriented languages.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
Noiseless testing framework
|
||||
|
||||
Version: 1.2.3
|
||||
Version: 1.2.3
|
||||
License: MIT
|
||||
|
||||
## About
|
||||
|
|
@ -278,28 +278,19 @@ ospec will automatically evaluate all `*.js` files in any folder named `/tests`.
|
|||
$ 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
|
||||
$ 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
|
||||
npm install ospec -g
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## API
|
||||
|
||||
*Square brackets denote optional arguments
|
||||
Square brackets denote optional arguments
|
||||
|
||||
### void o.spec(String title, Function tests)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue