Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/minoritea/nanowire

A minimal DOM patcher for HTML-over-the-wire
https://github.com/minoritea/nanowire

html html-over-the-wire html-renderer javascript typescript

Last synced: 1 day ago
JSON representation

A minimal DOM patcher for HTML-over-the-wire

Awesome Lists containing this project

README

        

# Nanowire
Nanowire is a minimal DOM patcher for HTML-over-the-wire.

# How to use
1. Enclose the element to be updated in a `` tag with a unique ID.
2. Give the following arguments to the `apply` function,
1. The DOM node or document that is the ancestor of the "nw-frame" tags to be updated,
2. Text containing "nw-frame" tags surrounding updates.

The following HTML is displayed first,
```html

Hello?

```

and then the following code is executed,

```javascript
import { apply } from 'nanowire';
apply(document, 'Hello, World!');
```

the result is as follows.
```html

Hello, World!

```

You can apply server-side rendered HTML as updates.
```javascript
fetch('your API').then(res => res.text()).then(text => apply(document, text));
```

The `nanowire/client` module provides short hands for fetch and apply.
```html

GET

POST
```

# Example

See the example.
```shell
# clone this repository and move inside.
$ cd example
$ yarn serve
```

# LICENSE
MIT License(see LICENSE file).