@blockquote-web-components/blockquote-controller-rxjs 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.js ADDED
@@ -0,0 +1,72 @@
1
+ /**
2
+ # BlockquoteControllerRxjs
3
+
4
+ ![Lit](https://img.shields.io/badge/lit-2.0.0-blue)
5
+
6
+ `BlockquoteControllerRxjs` is a Reactive Controller.
7
+
8
+ - Original idea by [Adrian Fâciu](https://github.com/adrianfaciu/rx-lit)
9
+ - [observables-litelement](https://adrianfaciu.dev/posts/observables-litelement/)
10
+
11
+ `BlockquoteControllerRxjs` provides a subscribe method to which pass the property we want to
12
+ assign values to and the Observable we want to subscribe.
13
+
14
+ - It works with [reactive properties](https://lit.dev/docs/components/properties/) and no-reactive properties
15
+ - It ignores calls on the same property with the same Observable
16
+ - It unsubscribes from old observable if called again on the same property with different Observable
17
+ - It unsubscribes when the component is removed
18
+
19
+ ## Usage
20
+
21
+ ```js
22
+ class BlockquoteControllerRxjsDemo extends LitElement {
23
+ static get is() {
24
+ return 'blockquote-controller-rxjs-demo';
25
+ }
26
+
27
+ static get properties() {
28
+ return {
29
+ _pos: {
30
+ type: Object,
31
+ attribute: false,
32
+ },
33
+ };
34
+ }
35
+
36
+ constructor() {
37
+ super();
38
+ this.rx = new BlockquoteControllerRxjs(this);
39
+ this._pos = { x: 0, y: 0 };
40
+ this.values$ = fromEvent(window, 'mousemove').pipe(
41
+ map(({ clientX, clientY }) => ({ x: clientX, y: clientY })),
42
+ );
43
+ }
44
+
45
+ connectedCallback() {
46
+ super.connectedCallback();
47
+
48
+ // Property and Observable.
49
+ this.rx.subscribe('_pos', this.values$);
50
+ }
51
+
52
+ render() {
53
+ return html`
54
+ <p>The mouse is at:</p>
55
+ <pre>
56
+ x: ${this._pos.x}
57
+ y: ${this._pos.y}
58
+ </pre
59
+ >
60
+ `;
61
+ }
62
+ }
63
+ ```
64
+
65
+ ## Exports
66
+
67
+ - BlockquoteControllerRxjs
68
+
69
+ @tagname blockquote-controller-rxjs
70
+ @element blockquote-controller-rxjs
71
+ */
72
+ export class ReadmElement extends HTMLElement {}
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
+ # blockquote-controller-rxjs
2
+
1
3
  # BlockquoteControllerRxjs
2
4
 
3
5
  ![Lit](https://img.shields.io/badge/lit-2.0.0-blue)
4
6
 
5
- `BlockquoteControllerRxjs` is a [Reactive Controller](https://lit.dev/docs/composition/controllers/#content)
7
+ `BlockquoteControllerRxjs` is a Reactive Controller.
6
8
 
7
9
  - Original idea by [Adrian Fâciu](https://github.com/adrianfaciu/rx-lit)
8
10
  - [observables-litelement](https://adrianfaciu.dev/posts/observables-litelement/)
@@ -19,45 +21,45 @@ assign values to and the Observable we want to subscribe.
19
21
 
20
22
  ```js
21
23
  class BlockquoteControllerRxjsDemo extends LitElement {
22
- static get is() {
23
- return 'blockquote-controller-rxjs-demo';
24
- }
24
+ static get is() {
25
+ return 'blockquote-controller-rxjs-demo';
26
+ }
25
27
 
26
- static get properties() {
27
- return {
28
- _pos: {
29
- type: Object,
30
- attribute: false,
31
- },
32
- };
33
- }
28
+ static get properties() {
29
+ return {
30
+ _pos: {
31
+ type: Object,
32
+ attribute: false,
33
+ },
34
+ };
35
+ }
34
36
 
35
- constructor() {
36
- super();
37
- this.rx = new BlockquoteControllerRxjs(this);
38
- this._pos = { x: 0, y: 0 };
39
- this.values$ = fromEvent(window, 'mousemove').pipe(
40
- map(({ clientX, clientY }) => ({ x: clientX, y: clientY })),
41
- );
42
- }
37
+ constructor() {
38
+ super();
39
+ this.rx = new BlockquoteControllerRxjs(this);
40
+ this._pos = { x: 0, y: 0 };
41
+ this.values$ = fromEvent(window, 'mousemove').pipe(
42
+ map(({ clientX, clientY }) => ({ x: clientX, y: clientY })),
43
+ );
44
+ }
43
45
 
44
- connectedCallback() {
45
- super.connectedCallback();
46
+ connectedCallback() {
47
+ super.connectedCallback();
46
48
 
47
- // Property and Observable.
48
- this.rx.subscribe('_pos', this.values$);
49
- }
49
+ // Property and Observable.
50
+ this.rx.subscribe('_pos', this.values$);
51
+ }
50
52
 
51
- render() {
52
- return html`
53
- <p>The mouse is at:</p>
54
- <pre>
55
- x: ${this._pos.x}
56
- y: ${this._pos.y}
57
- </pre
58
- >
59
- `;
60
- }
53
+ render() {
54
+ return html`
55
+ <p>The mouse is at:</p>
56
+ <pre>
57
+ x: ${this._pos.x}
58
+ y: ${this._pos.y}
59
+ </pre
60
+ >
61
+ `;
62
+ }
61
63
  }
62
64
  ```
63
65
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockquote-web-components/blockquote-controller-rxjs",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Webcomponent blockquote-controller-rxjs following open-wc recommendations",
5
5
  "keywords": [
6
6
  "lit",
@@ -19,17 +19,17 @@
19
19
  ],
20
20
  "scripts": {
21
21
  "analyze": "cem analyze --litelement --globs \"{src,define}/**/*.{js,ts}\" \"index.js\"",
22
- "analyze:doc": "npm run analyze && npx web-component-analyzer \"{src,define}/**/*.{js,ts}\" \"index.js\" --outFile README.md",
22
+ "analyze:doc": "npm run analyze && npx web-component-analyzer \"{src,define}/**/*.{js,ts}\" \"index.js\" \"README.js\" --outFile README.md",
23
23
  "build": "echo \"This is not a TypeScript project, so no need to build.\"",
24
24
  "dev:vite": "vite build",
25
25
  "format": "npm run format:eslint && npm run format:prettier && npm run format:stylelint",
26
26
  "format:eslint": "eslint \"**/*.{js,ts,html}\" --fix --ignore-path .eslintignore",
27
- "format:prettier": "prettier \"**/*.{js,ts,json,html,md}\" --write --ignore-path .eslintignore",
27
+ "format:prettier": "prettier \"**/*.{js,ts,json,html}\" --write --ignore-path .eslintignore",
28
28
  "format:stylelint": "stylelint \"**/*.{scss,css}\" --fix --allow-empty-input --ignore-path .eslintignore",
29
29
  "postinstall": "npm run sort:package",
30
30
  "lint": "npm run lint:eslint && npm run lint:prettier && npm run lint:stylelint",
31
31
  "lint:eslint": "eslint \"**/*.{js,ts,html}\" --ignore-path .eslintignore",
32
- "lint:prettier": "prettier \"**/*.{js,ts,json,html,md}\" --check --ignore-path .eslintignore",
32
+ "lint:prettier": "prettier \"**/*.{js,ts,json,html}\" --check --ignore-path .eslintignore",
33
33
  "lint:stylelint": "stylelint \"**/*.{scss,css}\" --allow-empty-input --ignore-path .eslintignore",
34
34
  "preview:vite": "vite preview",
35
35
  "sass:watch": "sass-style-template",
@@ -50,7 +50,7 @@
50
50
  "**/*.{js,ts,html}": [
51
51
  "npm run format:eslint"
52
52
  ],
53
- "**/*.{js,ts,json,html,md}": [
53
+ "**/*.{js,ts,json,html}": [
54
54
  "npm run format:prettier"
55
55
  ],
56
56
  "**/*.{scss,css}": [
@@ -118,11 +118,11 @@
118
118
  "rxjs": "^7.5.5"
119
119
  },
120
120
  "devDependencies": {
121
- "@blockquote-web-components/blockquote-base-common-dev-dependencies": "^1.2.0"
121
+ "@blockquote-web-components/blockquote-base-common-dev-dependencies": "^1.2.1"
122
122
  },
123
123
  "publishConfig": {
124
124
  "access": "public"
125
125
  },
126
126
  "customElements": "custom-elements.json",
127
- "gitHead": "e2be6111c893d804ac8212f350152c69ba6cfb98"
127
+ "gitHead": "f0d88eaef7c6b48711470dd2ff5c7c3eb554e0ec"
128
128
  }
@@ -5,8 +5,6 @@ const unsubscribe = Symbol('unsubscribe');
5
5
  const subscriptions = Symbol('subscriptions');
6
6
 
7
7
  /**
8
- # BlockquoteControllerRxjs
9
-
10
8
  ![Lit](https://img.shields.io/badge/lit-2.0.0-blue)
11
9
 
12
10
  `BlockquoteControllerRxjs` is a Reactive Controller.