1.3.11 • Published 9 months ago

@blockquote-web-components/blockquote-controller-rxjs v1.3.11

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

BlockquoteControllerRxjs

Lit

BlockquoteControllerRxjs is a Reactive Controller.

BlockquoteControllerRxjs provides a subscribe method to which pass the property we want to assign values to and the Observable we want to subscribe.

  • It works with reactive properties and non-reactive properties
  • It ignores calls on the same property with the same Observable
  • It unsubscribes from the old observable if called again on the same property with a different Observable
  • It unsubscribes when the component is removed

Demo

Open in StackBlitz

Usage

class BlockquoteControllerRxjsDemo extends LitElement {
  static get is() {
    return 'blockquote-controller-rxjs-demo';
  }

  static get properties() {
    return {
      _pos: {
        type: Object,
        attribute: false,
      },
    };
  }

  constructor() {
    super();
    this.rx = new BlockquoteControllerRxjs(this);
    this._pos = { x: 0, y: 0 };
    this.values$ = fromEvent(window, 'mousemove').pipe(
      map(({ clientX, clientY }) => ({ x: clientX, y: clientY })),
    );
  }

  connectedCallback() {
    super.connectedCallback();

    // Property and Observable.
    this.rx.subscribe('_pos', this.values$);
  }

  render() {
    return html`
      <p>The mouse is at:</p>
      <pre>
        x: ${this._pos.x}
        y: ${this._pos.y}
      </pre
      >
    `;
  }
}

src/BlockquoteControllerRxjs.js:

class: BlockquoteControllerRxjs

Fields
NamePrivacyTypeDefaultDescriptionInherited From
new Map()
Methods
NamePrivacyDescriptionParametersReturnInherited From
subscribepropKey, stream$
hostDisconnected

Exports

KindNameDeclarationModulePackage
jsBlockquoteControllerRxjsBlockquoteControllerRxjssrc/BlockquoteControllerRxjs.js

src/index.js:

Exports

KindNameDeclarationModulePackage
jsBlockquoteControllerRxjsBlockquoteControllerRxjs./BlockquoteControllerRxjs.js
1.3.10

9 months ago

1.3.11

9 months ago

1.3.9

9 months ago

1.3.7

10 months ago

1.3.6

10 months ago

1.3.8

10 months ago

1.3.5

12 months ago

1.3.4

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

2 years ago

1.1.1

2 years ago

1.1.2

2 years ago

1.0.19

2 years ago

1.1.0

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.9

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.12

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago