# lit-directive-subject

> This is a directive of lit-html for update (async mode) parts of your template. Change any part of your template without re-rendering

Latest version **0.0.2** (published 2021-01-23) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install lit-directive-subject
pnpm add lit-directive-subject
yarn add lit-directive-subject
bun add lit-directive-subject
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2021-01-23 |
| First published | 2021-01-19 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 37.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jimmy Collazos |
| Maintainers | jimmy-collazos |
| Keywords | lit-html, lit, webcomponents, customelements, lit-element, template, subject, subject-directive |

## Links

- npm: https://www.npmjs.com/package/lit-directive-subject
- Repository: https://github.com/jimmy-collazos/lit-directive-subject
- Homepage: https://github.com/jimmy-collazos/lit-directive-subject#README
- Issues: https://github.com/jimmy-collazos/lit-directive-subject/issues
- npm.io page: https://npm.io/package/lit-directive-subject

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2021-01-23
- 0.0.1 — 2021-01-19

## README

# Subject part directive of [lit-html]
<p align="center">
  <img alt="Export format: ESM" src="https://img.shields.io/badge/fomat-esm-yellowgreen" />
  <img alt="Distribution: Npm, Unpackage" src="https://img.shields.io/badge/%F0%9F%93%A6-npm%20unpk-yellowgreen" />
  <img alt="License: GPL 3.0" src="https://img.shields.io/badge/GPL 3.0-license-yellowgreen" />
</p>

This is a directive of [lit-html](https://lit-html.polymer-project.org/) for update (async mode) [parts](https://lit-html.polymer-project.org/api/interfaces/_lit_html_.part.html) of your template. Change any part of your template without re-rendering.

[🔗 See the demo](https://stackblitz.com/edit/lit-directive-subject-demo?file=index.js)

## Installation

Install from [NPM](https://www.npmjs.com/package/lit-directive-subject) or use from [Unpkg](https://unpkg.com/lit-directive-subject) CDN

**Npm**
```sh
npm install --save lit-directive-subject
```

**Unpkg**
```javascript
import {SubjetPartial} from 'https://unpkg.com/lit-directive-subject?module'
```

## API

## SubjetPartial

This is a class for create new partial context for updating in async mode.

### Methods:

* __part()__: directive for rendering values in you template
* __setValue(value)__: Set any value for rendering in your template
* __commit()__: Commit the current value and force to update template.

## Example:

```javascript
import {render, html} from 'lit-html'
import {SubjectPartial} from 'lit-directive-subject';

const partial = new SubjectPartial();

render(html`
  <h1>Demo</h1>
  <div>
    ${partial.part()}
  </div>
  `, window.container);


// Async updating
(function update() {
  partial.setValue(Math.random())
  partial.commit();
  setTimeout(update, 1000);
})();
```

---
_Source: https://npm.io/package/lit-directive-subject · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
