@blockquote-web-components/blockquote-controller-rxjs 1.0.23 → 1.1.0

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.md CHANGED
@@ -1,8 +1,6 @@
1
- # blockquote-controller-rxjs
2
-
3
1
  # BlockquoteControllerRxjs
4
2
 
5
- ![Lit](https://img.shields.io/badge/lit-2.0.0-blue)
3
+ ![Lit](https://img.shields.io/badge/lit-3.0.0-blue.svg)
6
4
 
7
5
  `BlockquoteControllerRxjs` is a Reactive Controller.
8
6
 
@@ -12,57 +10,87 @@
12
10
  `BlockquoteControllerRxjs` provides a subscribe method to which pass the property we want to
13
11
  assign values to and the Observable we want to subscribe.
14
12
 
15
- - It works with [reactive properties](https://lit.dev/docs/components/properties/) and no-reactive properties
13
+ - It works with [reactive properties](https://lit.dev/docs/components/properties/) and non-reactive properties
16
14
  - It ignores calls on the same property with the same Observable
17
- - It unsubscribes from old observable if called again on the same property with different Observable
15
+ - It unsubscribes from the old observable if called again on the same property with a different Observable
18
16
  - It unsubscribes when the component is removed
19
17
 
20
18
  ## Usage
21
19
 
22
20
  ```js
23
21
  class BlockquoteControllerRxjsDemo extends LitElement {
24
- static get is() {
25
- return 'blockquote-controller-rxjs-demo';
26
- }
22
+ static get is() {
23
+ return 'blockquote-controller-rxjs-demo';
24
+ }
27
25
 
28
- static get properties() {
29
- return {
30
- _pos: {
31
- type: Object,
32
- attribute: false,
33
- },
34
- };
35
- }
26
+ static get properties() {
27
+ return {
28
+ _pos: {
29
+ type: Object,
30
+ attribute: false,
31
+ },
32
+ };
33
+ }
36
34
 
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
- }
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
+ }
45
43
 
46
- connectedCallback() {
47
- super.connectedCallback();
44
+ connectedCallback() {
45
+ super.connectedCallback();
48
46
 
49
- // Property and Observable.
50
- this.rx.subscribe('_pos', this.values$);
51
- }
47
+ // Property and Observable.
48
+ this.rx.subscribe('_pos', this.values$);
49
+ }
52
50
 
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
- }
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
+ }
63
61
  }
64
62
  ```
65
63
 
66
- ## Exports
67
64
 
68
- - BlockquoteControllerRxjs
65
+ ### `src/BlockquoteControllerRxjs.js`:
66
+
67
+ #### class: `BlockquoteControllerRxjs`
68
+
69
+ ##### Fields
70
+
71
+ | Name | Privacy | Type | Default | Description | Inherited From |
72
+ | ---- | ------- | ---- | ----------- | ----------- | -------------- |
73
+ | | | | `new Map()` | | |
74
+
75
+ ##### Methods
76
+
77
+ | Name | Privacy | Description | Parameters | Return | Inherited From |
78
+ | ------------------ | ------- | ----------- | ------------------ | ------ | -------------- |
79
+ | `subscribe` | | | `propKey, stream$` | | |
80
+ | `hostDisconnected` | | | | | |
81
+
82
+ <hr/>
83
+
84
+ #### Exports
85
+
86
+ | Kind | Name | Declaration | Module | Package |
87
+ | ---- | -------------------------- | ------------------------ | ------------------------------- | ------- |
88
+ | `js` | `BlockquoteControllerRxjs` | BlockquoteControllerRxjs | src/BlockquoteControllerRxjs.js | |
89
+
90
+ ### `index.js`:
91
+
92
+ #### Exports
93
+
94
+ | Kind | Name | Declaration | Module | Package |
95
+ | ---- | -------------------------- | ------------------------ | --------------------------------- | ------- |
96
+ | `js` | `BlockquoteControllerRxjs` | BlockquoteControllerRxjs | ./src/BlockquoteControllerRxjs.js | |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockquote-web-components/blockquote-controller-rxjs",
3
- "version": "1.0.23",
3
+ "version": "1.1.0",
4
4
  "description": "Webcomponent blockquote-controller-rxjs following open-wc recommendations",
5
5
  "keywords": [
6
6
  "lit",
@@ -74,6 +74,7 @@
74
74
  {
75
75
  "files": "*.{scss,css}",
76
76
  "options": {
77
+ "printWidth": 280,
77
78
  "singleQuote": false
78
79
  }
79
80
  }
@@ -83,15 +84,30 @@
83
84
  "parserOptions": {
84
85
  "ecmaVersion": "latest"
85
86
  },
86
- "plugins": [
87
- "log-filenames"
88
- ],
89
87
  "extends": [
90
- "prettier",
91
- "@open-wc"
88
+ "@open-wc",
89
+ "prettier"
92
90
  ],
93
91
  "rules": {
94
92
  "class-methods-use-this": "off",
93
+ "indent": [
94
+ "error",
95
+ 2,
96
+ {
97
+ "SwitchCase": 1,
98
+ "ignoredNodes": [
99
+ "PropertyDefinition",
100
+ "TemplateLiteral > *"
101
+ ]
102
+ }
103
+ ],
104
+ "no-unused-expressions": [
105
+ "error",
106
+ {
107
+ "allowShortCircuit": true,
108
+ "allowTernary": true
109
+ }
110
+ ],
95
111
  "object-curly-newline": "off",
96
112
  "import/extensions": [
97
113
  "error",
@@ -105,33 +121,38 @@
105
121
  {
106
122
  "devDependencies": [
107
123
  "**/test/**/*.{js,ts}",
108
- "**/*.config.{js,mjs,cjs}",
109
- "**/*.conf.{js,mjs,cjs}"
124
+ "**/*.config.{js,ts,mjs,cjs}",
125
+ "**/*.conf.{js,ts,mjs,cjs}"
110
126
  ]
111
127
  }
112
128
  ],
113
129
  "import/no-unresolved": "off",
114
- "import/prefer-default-export": "off"
130
+ "import/prefer-default-export": "off",
131
+ "lit/no-classfield-shadowing": "off",
132
+ "lit/no-native-attributes": "off"
115
133
  }
116
134
  },
117
135
  "stylelint": {
118
136
  "extends": "stylelint-config-standard-scss",
119
137
  "rules": {
120
138
  "custom-property-pattern": null,
121
- "max-line-length": null
139
+ "max-line-length": null,
140
+ "no-duplicate-selectors": null,
141
+ "color-function-notation": null,
142
+ "alpha-value-notation": null
122
143
  }
123
144
  },
124
145
  "dependencies": {
125
- "lit": "^2.0.2",
146
+ "lit": "^3.1.0",
126
147
  "rxjs": "^8.0.0-alpha.12"
127
148
  },
128
149
  "devDependencies": {
129
- "@blockquote-web-components/blockquote-base-common-dev-dependencies": "^1.4.4",
130
- "@blockquote-web-components/blockquote-base-embedded-webview": "^1.5.2"
150
+ "@blockquote-web-components/blockquote-base-common-dev-dependencies": "^1.6.0",
151
+ "@blockquote-web-components/blockquote-base-embedded-webview": "^1.6.0"
131
152
  },
132
153
  "publishConfig": {
133
154
  "access": "public"
134
155
  },
135
156
  "customElements": "custom-elements.json",
136
- "gitHead": "f395648f8748ca2496345c5182b1b4dd8a60c662"
157
+ "gitHead": "c65690b8e735c0607858f3a14a381088721dc807"
137
158
  }
@@ -4,72 +4,70 @@ const unsubscribe = Symbol('unsubscribe');
4
4
  const subscriptions = Symbol('subscriptions');
5
5
 
6
6
  /**
7
- ![Lit](https://img.shields.io/badge/lit-2.0.0-blue)
8
-
9
- `BlockquoteControllerRxjs` is a Reactive Controller.
10
-
11
- - Original idea by [Adrian Fâciu](https://github.com/adrianfaciu/rx-lit)
12
- - [observables-litelement](https://adrianfaciu.dev/posts/observables-litelement/)
13
-
14
- `BlockquoteControllerRxjs` provides a subscribe method to which pass the property we want to
15
- assign values to and the Observable we want to subscribe.
16
-
17
- - It works with [reactive properties](https://lit.dev/docs/components/properties/) and no-reactive properties
18
- - It ignores calls on the same property with the same Observable
19
- - It unsubscribes from old observable if called again on the same property with different Observable
20
- - It unsubscribes when the component is removed
21
-
22
- ## Usage
23
-
24
- ```js
25
- class BlockquoteControllerRxjsDemo extends LitElement {
26
- static get is() {
27
- return 'blockquote-controller-rxjs-demo';
28
- }
29
-
30
- static get properties() {
31
- return {
32
- _pos: {
33
- type: Object,
34
- attribute: false,
35
- },
36
- };
37
- }
38
-
39
- constructor() {
40
- super();
41
- this.rx = new BlockquoteControllerRxjs(this);
42
- this._pos = { x: 0, y: 0 };
43
- this.values$ = fromEvent(window, 'mousemove').pipe(
44
- map(({ clientX, clientY }) => ({ x: clientX, y: clientY })),
45
- );
46
- }
47
-
48
- connectedCallback() {
49
- super.connectedCallback();
50
-
51
- // Property and Observable.
52
- this.rx.subscribe('_pos', this.values$);
53
- }
54
-
55
- render() {
56
- return html`
57
- <p>The mouse is at:</p>
58
- <pre>
59
- x: ${this._pos.x}
60
- y: ${this._pos.y}
61
- </pre
62
- >
63
- `;
64
- }
65
- }
66
- ```
67
-
68
- ## Exports
69
-
70
- - BlockquoteControllerRxjs
71
-
72
- */
7
+ * # BlockquoteControllerRxjs
8
+ *
9
+ * ![Lit](https://img.shields.io/badge/lit-3.0.0-blue.svg)
10
+ *
11
+ * `BlockquoteControllerRxjs` is a Reactive Controller.
12
+ *
13
+ * - Original idea by [Adrian Fâciu](https://github.com/adrianfaciu/rx-lit)
14
+ * - [observables-litelement](https://adrianfaciu.dev/posts/observables-litelement/)
15
+ *
16
+ * `BlockquoteControllerRxjs` provides a subscribe method to which pass the property we want to
17
+ * assign values to and the Observable we want to subscribe.
18
+ *
19
+ * - It works with [reactive properties](https://lit.dev/docs/components/properties/) and non-reactive properties
20
+ * - It ignores calls on the same property with the same Observable
21
+ * - It unsubscribes from the old observable if called again on the same property with a different Observable
22
+ * - It unsubscribes when the component is removed
23
+ *
24
+ * ## Usage
25
+ *
26
+ * ```js
27
+ * class BlockquoteControllerRxjsDemo extends LitElement {
28
+ * static get is() {
29
+ * return 'blockquote-controller-rxjs-demo';
30
+ * }
31
+ *
32
+ * static get properties() {
33
+ * return {
34
+ * _pos: {
35
+ * type: Object,
36
+ * attribute: false,
37
+ * },
38
+ * };
39
+ * }
40
+ *
41
+ * constructor() {
42
+ * super();
43
+ * this.rx = new BlockquoteControllerRxjs(this);
44
+ * this._pos = { x: 0, y: 0 };
45
+ * this.values$ = fromEvent(window, 'mousemove').pipe(
46
+ * map(({ clientX, clientY }) => ({ x: clientX, y: clientY })),
47
+ * );
48
+ * }
49
+ *
50
+ * connectedCallback() {
51
+ * super.connectedCallback();
52
+ *
53
+ * // Property and Observable.
54
+ * this.rx.subscribe('_pos', this.values$);
55
+ * }
56
+ *
57
+ * render() {
58
+ * return html`
59
+ * <p>The mouse is at:</p>
60
+ * <pre>
61
+ * x: ${this._pos.x}
62
+ * y: ${this._pos.y}
63
+ * </pre
64
+ * >
65
+ * `;
66
+ * }
67
+ * }
68
+ * ```
69
+ *
70
+ */
73
71
  export class BlockquoteControllerRxjs {
74
72
  constructor(host) {
75
73
  this[unsubscribe] = new Subject();
@@ -81,7 +79,9 @@ export class BlockquoteControllerRxjs {
81
79
  if (!isObservable(stream$)) {
82
80
  throw new Error('Invalid Observable!');
83
81
  }
82
+
84
83
  const existingSubscription = this[subscriptions].get(propKey);
84
+
85
85
  if (existingSubscription) {
86
86
  if (existingSubscription?.stream$ === stream$) {
87
87
  return stream$;
@@ -89,9 +89,7 @@ export class BlockquoteControllerRxjs {
89
89
  existingSubscription?.subscription?.unsubscribe();
90
90
  }
91
91
 
92
- // eslint-disable-next-line arrow-parens
93
92
  const subscription = stream$.pipe(takeUntil(this[unsubscribe])).subscribe(state => {
94
- // eslint-disable-next-line no-unused-expressions
95
93
  propKey in this.host && (this.host[propKey] = state);
96
94
  this.host.requestUpdate();
97
95
  });
package/README.js DELETED
@@ -1,72 +0,0 @@
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 {}