Skip to content

Commit e64ece6

Browse files
committed
add examples to readme
1 parent b09c441 commit e64ece6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,32 @@
77

88
A handy set of effects for use with [Hyperapp](https://github.com/jorgebucaran/hyperapp).
99

10+
## Getting Started
11+
12+
Here's a taste of how to use a common effect for making HTTP requests. The app displays inspiring quotes about design, fetching a new quote each time the user clicks on the current one. Go ahead and [try it online here](https://codepen.io/okwolf/pen/vPbMaa?editors=0010).
13+
14+
```js
15+
import { h, app } from "hyperapp"
16+
import { Http } from "hyperapp-fx"
17+
18+
const GetQuote = () => [
19+
"...",
20+
Http({
21+
url:
22+
"https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1",
23+
action: (_, [{ content }]) => content
24+
})
25+
]
26+
27+
app({
28+
init: "Click here for quotes",
29+
view: quote => <h1 onclick={GetQuote}>{quote}</h1>,
30+
container: document.body
31+
})
32+
```
33+
34+
More [examples](https://codepen.io/collection/ArmxQj) are available to show other in action.
35+
1036
## Installation
1137

1238
<pre>

0 commit comments

Comments
 (0)