Skip to content

Commit 53e3caa

Browse files
committed
show inline example of tracking the current width
fixes elm#72
1 parent e25ec2d commit 53e3caa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Browser/Events.elm

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,16 @@ onMouseUp =
183183

184184
{-| Subscribe to any changes in window size.
185185
186-
If you wanted to always track the current width, you could do something [like
187-
this](TODO).
186+
For example, you could track the current width by saying:
187+
188+
import Browser.Events as E
189+
190+
type Msg
191+
= GotNewWidth Int
192+
193+
subscriptions : model -> Cmd Msg
194+
subscriptions _ =
195+
E.onResize (\w h -> GotNewWidth w)
188196
189197
**Note:** This is equivalent to getting events from [`window.onresize`][resize].
190198

0 commit comments

Comments
 (0)