Skip to content

Commit b03b77a

Browse files
achou11yoshuawuyts
authored andcommitted
Docs corrections (#72)
* proofread Views page * proofread Stores page * proofread Routing page * Proofread Forms page * proofread Networking page * proofread Server Rendering page * proofread State Machines page
1 parent 56c7592 commit b03b77a

File tree

7 files changed

+36
-36
lines changed

7 files changed

+36
-36
lines changed

content/docs/forms/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ view: doc
55
excerpt:
66

77
Websites generally consist of 3 main elements: paragraph text, lists and forms.
8-
While paragraph text is generally straight forward to place on a page, lists &
8+
While paragraph text is generally straightforward to place on a page, lists and
99
forms require some more work. This section explains everything you need to know
1010
to work with forms in Choo.
1111
----
@@ -33,7 +33,7 @@ Forms are declared using the `<form>` tag. By themselves they don't do much, but
3333
they have a few important attributes that are good to know about.
3434

3535
The first attribute is `method=""`. This tells the form which HTTP method to
36-
use. By default it's set to `POST`, so often it's not needed to define this.
36+
use. By default it's set to `POST`, so it's often not necessary to define this.
3737

3838
The second attribute is `action=""`. This attribute tells the form where to
3939
redirect the page to when the submission was successful.
@@ -103,18 +103,18 @@ that looks like:
103103

104104
## Handling Form Submissions As Multipart
105105
So far we've seen how to create basic HTML forms with validation. This is a
106-
great starting point, but often we'll want to control submissions using
106+
great starting point, but we'll often want to control submissions using
107107
JavaScript.
108108

109-
Perhaps we can pre-populate some input fields. Perhaps there's input fields that
109+
Perhaps we can pre-populate some input fields. Perhaps there are input fields that
110110
rely on the values of other input fields. Starting off with JS from the start
111111
allows us to change the behavior without needing to change the architecture.
112112

113113
Creating forms with Choo is almost identical to basic HTML. The main difference
114114
is that we create a `'submit'` event handler, and we control sending the data
115115
using `window.fetch()`.
116116

117-
Let's create a form that sends data down as `'multipart/form-data`. We'll talk
117+
Let's create a form that sends data down as `multipart/form-data`. We'll talk
118118
about how to submit it as JSON in the next section.
119119

120120
```js
@@ -166,7 +166,7 @@ function main () { // 1.
166166

167167
1. We create a basic Choo app, and a single view that renders a `<form>`
168168
element. Inside it we listen for the `'submit'` event by setting the
169-
`onsubmit=` attribute.
169+
`onsubmit` attribute.
170170
2. We create a handler for the `'submit'` event. This will fire whenever a user
171171
clicks the `type="submit"` button (or an equivalent action).
172172
3. Before we can handle the form's `'submit'` event, we need to disable the

content/docs/networking/index.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ that includes high-level APIs to do networking, sandboxed code execution and
1313
disk access. It runs on almost every platform, behaves similarly everywhere, and
1414
is always kept backwards compatible.
1515

16-
An important part of this machinery is networking. In the browser, there's 8 (or
16+
An important part of this machinery is networking. In the browser, there are 8 (or
1717
so) different ways to access the network:
1818

1919
- By navigating to a new page
20-
- Through `<script>`, `<link>`, & other tags.
20+
- Through `<script>`, `<link>`, and other tags.
2121
- Using `preload` headers.
22-
- Using `new XMLHTTPRequest()`, `window.fetch()`, & `navigator.sendBeacon()`.
22+
- Using `new XMLHTTPRequest()`, `window.fetch()`, and `navigator.sendBeacon()`.
2323
- Using (dynamic) `import()`.
2424
- Using the Server Sent Events API.
2525
- Using the WebSocket API.
@@ -45,31 +45,31 @@ The browser has several ways of performing HTTP requests.
4545
- __Navigating to a new page:__ performs an HTTP request whenever you type in a
4646
url in your browser. The server then replies with some `index.html` file which
4747
contains more links to assets and other pages.
48-
- __Through `<script>`, `<link>` & other tags:__ When an `index.html` page is
48+
- __Through `<script>`, `<link>` and other tags:__ When an `index.html` page is
4949
loaded, the browser will read out all `<link>` and `<script>` tags in the
5050
document's head. This will trigger requests for more resources, which in turn
5151
can request even more resources. There's also the `<a>` and `<img>` tags,
5252
which act similarly.
5353
- __Using `preload` headers.__ When a browser page is loaded, the server can
5454
set headers for additional resources that should be loaded. The browser then
5555
proceeds to request those.
56-
- __Using `new XMLHTTPRequest()` & `window.fetch()`:__ In order to make dynamic
56+
- __Using `new XMLHTTPRequest()` and `window.fetch()`:__ In order to make dynamic
5757
requests to say, a JSON API, you can use these APIs. `XMLHTTPRequest` is the
5858
classic way of performing requests, but these days there's the more modern
5959
`window.fetch()` API. Regardless of which API you use, they produce similar
6060
results.
6161
- __Using `navigator.sendBeacon()`:__ Sometimes you want to perform an HTTP
62-
Request, but want to allow more important requests to be prioritized first.
63-
For example with analytics data. The `sendBeacon()` API, allows for exactly
62+
Request, but want to allow more important requests to be prioritized first,
63+
such as with analytics data. The `sendBeacon()` API allows for exactly
6464
this: it allows you to create an HTTP POST request, but schedules it to occur
65-
in the background. Even if the page is closed before the request had a chance
65+
in the background, even if the page is closed before the request had a chance
6666
to complete.
6767
- __Using (dynamic) `import`:__ Scripts can request other scripts, by using the
6868
`import` syntax. This can either be dynamic or static - but in both cases it
6969
makes an HTTP request to require JavaScript.
7070

7171
### Fetch
72-
There's many ways of creating an HTTP request, but the most common one these
72+
There are many ways to create an HTTP request, but the most common one these
7373
days is using `fetch()`. In Choo you might want to trigger a request based on
7474
some other event coming through the EventEmitter. Let's look at a brief example
7575
of how to trigger a request based on a Choo event:
@@ -103,10 +103,10 @@ app.store((state, emitter) => {
103103
endpoint. The url is dynamically created based on the username that's passed.
104104
3. We know the response will be JSON, so we try and convert the binary blob to
105105
a valid JavaScript Object.
106-
5. Now that we have an object, we add the new tweets to our existing list of
106+
4. Now that we have an object, we add the new tweets to our existing list of
107107
tweets. Once the new data is set, we emit the `'render'` event to trigger a
108108
DOM update.
109-
6. If any of the steps above failed for any reason, we emit the `'error'` event.
109+
5. If any of the steps above failed for any reason, we emit the `'error'` event.
110110
If this was a real-world project, this is where we'd also make sure we had a
111111
good user-facing error, and would report the error to our analytics server.
112112
Good error handling is a very imporant aspect of production applications.
@@ -194,7 +194,7 @@ app.store((state, emitter) => {
194194
6. If for some reason a parsing error occurs, we should emit an `'sse:error'`
195195
event.
196196
7. If everything has gone well, we can expose the event to the rest of our app
197-
using the `sse:message` event.
197+
using the `'sse:message'` event.
198198
8. Connection errors can occur. The connection can be closed from the server,
199199
it can be reconnecting or some other unknown error might have occured.
200200
9. If the connection was closed cleanly, we emit the `'sse:closed'` connection,
@@ -277,7 +277,7 @@ app.store((state, emitter) => {
277277
`'ws:open'`.
278278
6. We can now tell the system that our websocket is ready to be used, so we
279279
update our state before that.
280-
7. Now that we're reading to start listening for events, we can emit `'ws:open`.
280+
7. Now that we're reading to start listening for events, we can emit `'ws:open'`.
281281
8. Whenever we receive a `'message'` event, we emit the `'ws:message'` event.
282282
9. Whenever the connection closes, we set `state.websocket.open` to `false` and
283283
we emit the `'ws:close'` event.
@@ -287,5 +287,5 @@ app.store((state, emitter) => {
287287
And that's it! We hope you've now read enough to get started with network
288288
protocols in the browser! There's much more to explore, and as the web evolves
289289
so will the protocols. But we're confident that interfacing Choo with the
290-
browser's networking protocols will always remain straight forward and
290+
browser's networking protocols will always remain straightforward and
291291
convenient. Happy (network) hacking!

content/docs/routing/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function view () { // 4.
5050

5151
1. We need an instance of Choo to add our routes to, so let's create that
5252
first.
53-
2. We're going to add a view on the `'/` route. This means that if people
53+
2. We're going to add a view on the `/` route. This means that if people
5454
navigate to `oursite.com`, this will be the route that is enabled.
5555
3. Now that we have our view, we can start rendering our application.
5656
4. We declare our view at the bottom of the page. Thanks to [scope
@@ -167,8 +167,8 @@ So `?foo=bar&bin=baz` would be exposed as `state.query.foo` and
167167
`state.query.bin`.
168168

169169
## Dynamic routing
170-
Sometimes there will be pages that have the same layout, but different data.
171-
For example user pages, or blog entries. This requires _dynamic routing_. In
170+
Sometimes there will be pages that have the same layout but different data,
171+
such as user pages or blog entries. This requires _dynamic routing_. In
172172
Choo we have two types of syntax for dynamic routing.
173173

174174
### Params
@@ -259,7 +259,7 @@ html`
259259
```
260260

261261
## Programmatic Navigation
262-
Often it's needed to change routes after some event happens. For example,
262+
It's often necessary to change routes after some event happens. For example,
263263
someone logs in, and we need to redirect them to the logged in page. We need
264264
programmatic navigation.
265265

content/docs/server-rendering/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ This section shows how to effectively render Choo apps in Node.
99
text:
1010
Building fast applications is a tricky challenge. Usually you want to optimize
1111
the [time to first
12-
render](https://developers.google.com/web/fundamentals/performance/critical-rendering-path/).
13-
And then make sure the page becomes interactive quickly. And once that's done,
12+
render](https://developers.google.com/web/fundamentals/performance/critical-rendering-path/)
13+
and then make sure the page becomes interactive quickly. And once that's done,
1414
you want it to all keep feeling snappy. And then some.
1515

1616
Server rendering is a technique to improve time to first render in applications

content/docs/state-machines/index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ In this section we'll learn how to use and implement state machines.
88
----
99
text:
1010
If you work in software long enough, you'll have to deal with legacy codebases.
11-
but you'll also have had the chance to start projects from scratch. And
11+
But you'll also have had the chance to start projects from scratch. And
1212
eventually you'll see your project become a legacy codebase itself.
1313

1414
A big challenge in software engineering is: "how do we keep applications
15-
maintainable?" Because if software isn't maintainable, it can be hard to change,
15+
maintainable?" Because if software isn't maintainable, it can be hard to change
1616
and get other people involved. This is not great for many reasons, but most
1717
importantly: it makes working with the code less fun!
1818

@@ -62,9 +62,9 @@ transitions, expanding the graph.
6262
## State machines in JavaScript
6363
Let's implement the traffic light example in JavaScript. In order for this to
6464
work, we'll need to implement:
65-
- Saving the states & transitions in an Object
66-
- The core state machine algorithm
67-
- Creating a small, stateful class to hold the state
65+
- Saving the states and transitions in an Object.
66+
- The core state machine algorithm.
67+
- Creating a small, stateful class to hold the state.
6868
- Combining all of these to form the complete state machine.
6969

7070
Let's dig in!
@@ -137,8 +137,8 @@ The value of `.state` is the current state we're in. If an invalid transtion
137137
occurs, the state machine throws an error explaining which transition was
138138
invalid.
139139

140-
### Combining Data & State
141-
Now that we have all our individual bits, let's combine it all together:
140+
### Combining Data and State
141+
Now that we have all of our individual bits, let's combine it all together:
142142

143143
```js
144144
var machine = new StateMachine('green', {

content/docs/stores/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ app.use((state, emitter) => {
6363
```
6464

6565
#### Notes on DOM loading
66-
- If you're loading stores dynamically, the `'DOMContentLoaded` event will have
66+
- If you're loading stores dynamically, the `'DOMContentLoaded'` event will have
6767
fired by the time you start listening for it. Instead use the
6868
[document-ready](https://github.com/bendrucker/document-ready) package. It's
69-
what Choo uses internally to provide the `DOMContentLoaded` event, so there
69+
what Choo uses internally to provide the `'DOMContentLoaded'` event, so there
7070
is no size cost in using it.
7171

7272
## Updating state and rendering

content/docs/views/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ application's flow is easy to reason about, views cannot attach listeners on
111111
the event bus themselves. This is where "data down, events up" becomes
112112
visible in the code: the view only has access to `emit()`, while anything that is
113113
declared through `app.use()`, such as a store, has access to the whole event bus
114-
throught `emitter`. This can both send events with `emitter.emit()`, as well as
114+
through `emitter`. This can both send events with `emitter.emit()`, as well as
115115
receive them with `emitter.on()`.
116116

117117
There are many events available on DOM elements, and most are available as

0 commit comments

Comments
 (0)