Skip to content

Commit 9471c34

Browse files
committed
add screenshot of counter-reset-keyboard subscription tests passing #57
1 parent a326d58 commit 9471c34

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

Diff for: elmish.md

+18-6
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,8 @@ If you get "stuck", checkout:
18651865
### `subscriptions` for event listeners
18661866

18671867
In Elm, when we want to "listen" for an event or "external input"
1868-
we use `subscriptions`. Examples include:
1868+
we use `subscriptions`. <br />
1869+
Examples include:
18691870

18701871
+ [Keyboard events](http://package.elm-lang.org/packages/elm-lang/keyboard/latest/Keyboard)
18711872
+ [Mouse movements & clicks](http://package.elm-lang.org/packages/elm-lang/mouse/latest/Mouse)
@@ -1883,11 +1884,11 @@ and consider an alternative User Interaction/Experience: Keyboard!
18831884

18841885
#### Use-case: Use Up/Down Keyboard (Arrow) Keys to Increment/Decrement Counter
18851886

1886-
As a user <br />
1887-
I would like to use the keyboard **`[↑]`** (Up) and **`[↓]`** (Down) arrow keys
1887+
***As a user*** <br />
1888+
***I would like*** to use the keyboard **`[↑]`** (Up) and **`[↓]`** (Down) arrow keys <br />
18881889
to signal the **Increment** and **Decrement** action (_respectively_)
1889-
of the Counter.
1890-
So that I don't have to use a mouse to click a button.
1890+
of the Counter. <br />
1891+
***So that*** I don't have to use a mouse to click a button.
18911892

18921893
![up-down-arrrow-keys](https://user-images.githubusercontent.com/194400/43962720-4cbfb192-9cb0-11e8-9c45-63e7644f1cf6.png)
18931894

@@ -1989,12 +1990,23 @@ so the last assertion always passes.
19891990

19901991
#### `subscriptions`_Implementation_: Keyboard Keys Increment/Decrement Counter!
19911992

1992-
We could spend an hour googling or I can _give_ you the sample code
1993+
Once again, try to _think_ of how you would implement
1994+
a subscriptions function and _attempt_ to write the code.
19931995

1996+
Don't be disheartened if you have "_no idea_" how to solve this one.
1997+
If you are relatively recent to JavaScript,
1998+
it is _unlikely_ that you have come across event listeners.
19941999

2000+
It's "OK" to "take a peek" at the sample code:
2001+
[**`examples/counter-reset-keyboard/counter.js`**](https://github.com/dwyl/learn-elm-architecture-in-javascript/pull/45/files#diff-97353eabc55df91dbb3f96ba5a000a1aR26)
19952002

2003+
Once you add the **`subscriptions`** function to
2004+
**`examples/counter-reset-keyboard/counter.js`**,
2005+
Your tests should pass:
19962006

2007+
![counter-reset-keyboard-subscriptions-tests-passing](https://user-images.githubusercontent.com/194400/43981911-b6413dda-9ceb-11e8-8514-44fc1f88c3fe.png)
19972008

2009+
Well done!
19982010

19992011
<br />
20002012

0 commit comments

Comments
 (0)