Skip to content

Commit

Permalink
Added some missing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Oct 3, 2017
1 parent 9a2de6f commit 3f53a4f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
30 changes: 30 additions & 0 deletions API.md
Expand Up @@ -17,6 +17,7 @@ _This reference guide lists all methods exposed by MST. Contributions like lingu
- [ComplexType](#complextype-2)
- [ComplexType](#complextype-3)
- [ComplexType](#complextype-4)
- [createActionTrackingMiddleware](#createactiontrackingmiddleware)
- [decorate](#decorate)
- [destroy](#destroy)
- [detach](#detach)
Expand Down Expand Up @@ -58,6 +59,7 @@ _This reference guide lists all methods exposed by MST. Contributions like lingu
- [Type](#type-6)
- [Type](#type-7)
- [Type](#type-8)
- [typecheck](#typecheck)
- [types.array](#typesarray)
- [types.boolean](#typesboolean)
- [types.compose](#typescompose)
Expand Down Expand Up @@ -182,6 +184,22 @@ Returns **T**

## ComplexType

## createActionTrackingMiddleware

Convenience utility to create action based middleware that supports async processes more easily.
All hooks are called for both synchronous and asynchronous actions. Except that either `onSuccess` or `onFail` is called

The create middleware tracks the process of an action (assuming it passes the `filter`).
`onResume` can return any value, which will be passed as second argument to any other hook. This makes it possible to keep state during a process.

See the `atomic` middleware for an example

**Parameters**

- `hooks`

Returns **IMiddlewareHandler**

## decorate

Binds middleware to a specific action
Expand Down Expand Up @@ -260,6 +278,8 @@ Returns **IType<any, any>**
Returns the environment of the current state tree. For more info on environments,
see [Dependency injection](https://github.com/mobxjs/mobx-state-tree#dependency-injection)

Returns an empty environment if the tree wasn't initialized with an environment

**Parameters**

- `target` **IStateTreeNode**
Expand Down Expand Up @@ -573,6 +593,16 @@ Returns **any**

## Type

## typecheck

Run's the typechecker on the given type.
Throws if the given value is not according the provided type specification.

**Parameters**

- `type` **IType<any, any>**
- `value` **any**

## types.array

Creates an index based collection type who's children are all of a uniform declared type.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -766,6 +766,7 @@ See the [full API docs](API.md) for more details.
| [`applyAction(node, actionDescription)`](API.md#applyaction) | Replays an action on the targeted node |
| [`applyPatch(node, jsonPatch)`](API.md#applypatch) | Applies a JSON patch, or array of patches, to a node in the tree |
| [`applySnapshot(node, snapshot)`](API.md#applysnapshot) | Updates a node with the given snapshot |
| [`createActionTrackingMiddleware`](API.md#createactiontrackingmiddleware) | Utility to make writing middleware that track async actions less cumbersome |
| [`clone(node, keepEnvironment?: true \| false \| newEnvironment)`](API.md#clone) | Creates a full clone of the given node. By default preserves the same environment |
| [`decorate(middleware, function)`](API.md#decorate) | Attaches middleware to a specific action (or process) |
| [`destroy(node)`](API.md#destroy) | Kills `node`, making it unusable. Removes it from any parent in the process |
Expand Down Expand Up @@ -794,6 +795,7 @@ See the [full API docs](API.md) for more details.
| [`recordPatches(node)`](API.md#recordpatches) | Creates a recorder that listens to all patches emitted by the node. Call `.stop()` on the recorder to stop this, and `.replay(target)` to replay the recorded patches on another tree |
| [`resolve(node, path)`](API.md#resolve) | Resolves a `path` (json path) relatively to the given `node` |
| [`splitJsonPath(path)`](API.md#splitjsonpath) | Splits and unescapes the given JSON `path` into path parts |
| [`typecheck(type, value)`](API.md#typecheck) | Typechecks a value against a type. Throws on errors. Use this if you need typechecks even in a production build. |
| [`tryResolve(node, path)`](API.md#tryresolve) | Like `resolve`, but just returns `null` if resolving fails at any point in the path |
| [`unprotect(node)`](API.md#unprotect) | Unprotects `node`, making it possible to directly modify any value in the subtree, without actions |
| [`walk(startNode, (node) => void)`](API.md#walk) | Performs a depth-first walk through a tree |
Expand Down
1 change: 1 addition & 0 deletions src/types/type-checker.ts
Expand Up @@ -92,6 +92,7 @@ export function typecheck(type: IType<any, any>, value: any): void {
/**
* Run's the typechecker on the given type.
* Throws if the given value is not according the provided type specification.
* Use this if you need typechecks even in a production build (by default all automatic runtime type checks will be skipped in production builds)
*
* @alias typecheck
* @export
Expand Down

0 comments on commit 3f53a4f

Please sign in to comment.