1.4.12 • Published 7 months ago

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

Weekly downloads
-
License
MIT
Repository
-
Last release
7 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.4.6

10 months ago

1.4.5

10 months ago

1.4.4

11 months ago

1.4.3

11 months ago

1.4.2

11 months ago

1.4.1

12 months ago

1.4.0

12 months ago

1.3.12

12 months ago

1.4.9

8 months ago

1.4.11

7 months ago

1.4.8

8 months ago

1.4.10

7 months ago

1.4.7

8 months ago

1.4.12

7 months ago

1.3.10

1 year ago

1.3.11

1 year ago

1.3.9

1 year ago

1.3.7

1 year ago

1.3.6

1 year ago

1.3.8

1 year ago

1.3.5

1 year 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

2 years ago

1.2.0

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years 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

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 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