Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lit-directive-reactive

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lit-directive-reactive

Lit-html directive for observer pattern (Reactive)

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Social Media Photo by Ryan Stone on Unsplash

:twisted_rightwards_arrows: Directiva lit-html para la programación rectiva

Formato de exportación: ESM Distribución: Npm, Unpackage Licencia: GPL 3.0

This lit-html directive is for use some parts of your templates like an observable (Reactive programming).

Use with RxJs, most.js and xstream or wharever library with Observable and Subject implementation.

See the demo with example.

Installation

Install from NPM or use from Unpkg CDN

Npm

npm install --save lit-directive-reactive

Unpkg

import {subscribeDirective, toSubjectDirective} from 'https://unpkg.com/lit-directive-reactive?module'

API

# subscribe(observable)

Support for AttributePart, BooleanAttributePart, EventPart, NodePart, PropertyPart

Update template Part value with received value on Observable (next method)

Parameters

  • observable: Observable object to subscribe

Return value

return template Part of lit-html

Example

import {render, html} from 'lit-html'
import {subscribeDirective} from 'lit-directive-reactive';
import { Observable } from 'rxjs';

const counterObservable = new Observable(subscriber => {
  let count = 0;
  subscriber.next(count);
  setTimeout(() => {
    subscriber.next(++count);
  }, 1000);
});

render(html`
      <span> ${subscribeDirective(counterObservable)} </span>
      <input value="${subscribeDirective(counterObservable)}" />
      `, window.container);

# toSubject(subject)

Currently support for EventPart

Emit event value to Subject

Parameters

  • subject: Subject to emit event value

Return value

return template Part of lit-html

Example

import {render, html} from 'lit-html'
import {toSubjectDirective} from 'lit-directive-reactive';
import { Subject } from 'rxjs';

const subject = new Subject();

subject.subscribe(ev => console.log(ev));

render(html`
      <button @click=${toSubject(subject)}> +1 </button>
      `, window.container);

Keywords

FAQs

Package last updated on 23 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc