Skip to content

Commit

Permalink
Adjusts documentation for load and fromScript
Browse files Browse the repository at this point in the history
  • Loading branch information
goatslacker committed Sep 9, 2016
1 parent 592d434 commit 52030ed
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ hypernova({

```typescript
type DeserializedData = { [x: string]: any };
type Node = { node: HTMLElement, data: DeserializedData };
type ServerRenderedPair = { node: HTMLElement, data: DeserializedData };

function load(name: string): Node {}
function load(name: string): Array<ServerRenderedPair> {}
```

Looks up the server-rendered DOM markup and its corresponding `script` JSON payload and returns it.
Expand Down Expand Up @@ -297,10 +297,11 @@ An interface that allows you to create extra `script` tags for loading more data
```typescript
type DeserializedData = { [x: string]: any };

function fromScript(attr: string, key: string): DeserializedData {}
function fromScript(attr: string, key: string, id: string): DeserializedData {}
```

The inverse of `toScript`, this function runs on the browser and attempts to find and `JSON.parse` the contents of the server generated script.
`attr` is a custom data attribute that is included in the HTML element, `key` is the data attribute's value and will be used to find the element on the browser, `id` is optional and if included will attempt to find the DOM node with `data-hypernova-id="${id}"`.

### Server

Expand Down

0 comments on commit 52030ed

Please sign in to comment.