@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 +72 -0
- package/README.md +37 -35
- package/package.json +7 -7
- package/src/BlockquoteControllerRxjs.js +0 -2
package/README.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
# BlockquoteControllerRxjs
|
|
3
|
+
|
|
4
|
+

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

|
|
4
6
|
|
|
5
|
-
`BlockquoteControllerRxjs` is a
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
static get is() {
|
|
25
|
+
return 'blockquote-controller-rxjs-demo';
|
|
26
|
+
}
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
static get properties() {
|
|
29
|
+
return {
|
|
30
|
+
_pos: {
|
|
31
|
+
type: Object,
|
|
32
|
+
attribute: false,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
super.connectedCallback();
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
// Property and Observable.
|
|
50
|
+
this.rx.subscribe('_pos', this.values$);
|
|
51
|
+
}
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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": "
|
|
127
|
+
"gitHead": "f0d88eaef7c6b48711470dd2ff5c7c3eb554e0ec"
|
|
128
128
|
}
|