https://github.com/samccone/strands
https://github.com/samccone/strands
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/samccone/strands
- Owner: samccone
- Created: 2015-01-22T20:58:34.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-22T20:59:29.000Z (over 11 years ago)
- Last Synced: 2025-03-23T04:27:25.920Z (over 1 year ago)
- Size: 117 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Strands
A Router based around state and Promise based resolvers.
Each route is defined under a "state key" that is decoupled from the route.
Every state can define `before` and `after` tasks.
`before` tasks are evaluated before the previous state is left, the route will not change until all have been resolved. (if any throw or are rejected the state will not change)
`after` tasks are evaluated after the state has changed.
```js
myRouter = new Strands({
"edit-cat": {
route: "cat/edit/:id",
before: [fetchCat],
after: [saveSave]
}
})
myRouter.go("edit-cat");
function fetchCat(params) {
return fetch("cat");
}
function saveCat() {
return fetch("cat", {
method: "post",
body: serializeCat()
})
}
```