├── .eslintrc.js
├── .github
├── ISSUE_TEMPLATE
│ └── bug_report.md
└── workflows
│ └── greetings.yml
├── .gitignore
├── .gitlab-ci.yml
├── .prettierrc.json
├── CODE-OF-CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── assets
└── pictures
│ └── vue-rx.jpg
├── example
├── createObservableMethod.html
├── fromDom.html
├── ref.html
├── subscribeTo.html
├── vStream.html
├── vStream2.html
├── watch.html
└── watchAsObservable.html
├── package-lock.json
├── package.json
├── pull_request_template.md
├── rollup.config.js
├── src
├── directives
│ └── stream.js
├── index.js
├── methods
│ ├── createObservableMethod.js
│ ├── fromDomEvent.js
│ ├── ref.js
│ ├── subscribeTo.js
│ ├── watch.js
│ └── watchAsObservable.js
├── mixin.js
├── umd-aliases
│ ├── operators.js
│ └── rxjs.js
└── util.js
├── test
└── test.js
└── types
├── index.d.ts
├── test
├── index.ts
└── tsconfig.json
├── tsconfig.json
└── typings.json
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | env: {
4 | node: true,
5 | },
6 | extends: ["plugin:vue/vue3-essential", "eslint:recommended"],
7 | parserOptions: {
8 | ecmaVersion: 2020,
9 | },
10 | rules: {
11 | "no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
12 | "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
13 | "no-inferrable-types": "off",
14 | "class-name": "off",
15 | "@typescript-eslint/ban-ts-ignore": "off",
16 | "@typescript-eslint/no-var-requires": "off",
17 | "no-var": "off",
18 | "vue/no-ref-as-operand": "off",
19 | },
20 | overrides: [
21 | {
22 | files: [
23 | "**/__tests__/*.{j,t}s?(x)",
24 | "**/tests/unit/**/*.spec.{j,t}s?(x)",
25 | ],
26 | env: {
27 | mocha: true,
28 | },
29 | },
30 | ],
31 | };
32 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/.github/workflows/greetings.yml:
--------------------------------------------------------------------------------
1 | name: Greetings
2 |
3 | on: [pull_request, issues]
4 |
5 | jobs:
6 | greeting:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/first-interaction@v1
10 | with:
11 | repo-token: ${{ secrets.GITHUB_TOKEN }}
12 | issue-message: 'Hi ! Thanks for this issue, i will look at it quickly !'' first issue'
13 | pr-message: 'Hi ! Thanks for your awesome contribution, i will look at it quickly !'' first pr'
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | dist
2 | node_modules
3 | coverage
4 | .DS_Store
5 | .idea
6 | .vscode
7 | .nyc_output
--------------------------------------------------------------------------------
/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | image: node:latest
2 |
3 | stages:
4 | - test
5 |
6 | test:
7 | script:
8 | - npm install
9 | - npm run build
10 | - npm run test
11 |
--------------------------------------------------------------------------------
/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "prettier.singleQuote": true,
3 | "prettier.bracketSpacing": true,
4 | "prettier.enable": true,
5 | "prettier.semi": false,
6 | "prettier.useEditorConfig": true
7 | }
8 |
--------------------------------------------------------------------------------
/CODE-OF-CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | contact@boucham-amine.fr.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to Vue next rx
2 |
3 | First off, thanks for taking the time to contribute! ❤️
4 |
5 | All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. 🎉
6 |
7 | > And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:
8 | > - Star the project
9 | > - Tweet about it
10 | > - Refer this project in your project's readme
11 | > - Mention the project at local meetups and tell your friends/colleagues
12 |
13 |
14 | ## Table of Contents
15 |
16 | - [I Have a Question](#i-have-a-question)
17 | - [I Want To Contribute](#i-want-to-contribute)
18 | - [Reporting Bugs](#reporting-bugs)
19 | - [Suggesting Enhancements](#suggesting-enhancements)
20 | - [Your First Code Contribution](#your-first-code-contribution)
21 | - [Improving The Documentation](#improving-the-documentation)
22 | - [Styleguides](#styleguides)
23 | - [Commit Messages](#commit-messages)
24 | - [Join The Project Team](#join-the-project-team)
25 |
26 |
27 |
28 | ## I Have a Question
29 |
30 | > If you want to ask a question, we assume that you have read the available [Documentation](https://github.com/NOPR9D/vue-next-rx/blob/main/README.md).
31 |
32 | Before you ask a question, it is best to search for existing [Issues](https://github.com/NOPR9D/vue-next-rxissues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.
33 |
34 | If you then still feel the need to ask a question and need clarification, we recommend the following:
35 |
36 | - Open an [Issue](https://github.com/NOPR9D/vue-next-rxissues/new).
37 | - Provide as much context as you can about what you're running into.
38 | - Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant.
39 |
40 | We will then take care of the issue as soon as possible.
41 |
42 |
56 |
57 | ## I Want To Contribute
58 |
59 | > ### Legal Notice
60 | > When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license.
61 |
62 | ### Reporting Bugs
63 |
64 |
65 | #### Before Submitting a Bug Report
66 |
67 | A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.
68 |
69 | - Make sure that you are using the latest version.
70 | - Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://github.com/NOPR9D/vue-next-rx/blob/main/README.md). If you are looking for support, you might want to check [this section](#i-have-a-question)).
71 | - To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/NOPR9D/vue-next-rxissues?q=label%3Abug).
72 | - Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
73 | - Collect information about the bug:
74 | - Stack trace (Traceback)
75 | - OS, Platform and Version (Windows, Linux, macOS, x86, ARM)
76 | - Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant.
77 | - Possibly your input and the output
78 | - Can you reliably reproduce the issue? And can you also reproduce it with older versions?
79 |
80 |
81 | #### How Do I Submit a Good Bug Report?
82 |
83 | > You must never report security related issues, vulnerabilities or bugs to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to .
84 |
85 |
86 | We use GitHub issues to track bugs and errors. If you run into an issue with the project:
87 |
88 | - Open an [Issue](https://github.com/NOPR9D/vue-next-rxissues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
89 | - Explain the behavior you would expect and the actual behavior.
90 | - Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
91 | - Provide the information you collected in the previous section.
92 |
93 | Once it's filed:
94 |
95 | - The project team will label the issue accordingly.
96 | - A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced.
97 | - If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution).
98 |
99 |
100 |
101 |
102 | ### Suggesting Enhancements
103 |
104 | This section guides you through submitting an enhancement suggestion for Vue next rx, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions.
105 |
106 |
107 | #### Before Submitting an Enhancement
108 |
109 | - Make sure that you are using the latest version.
110 | - Read the [documentation](https://github.com/NOPR9D/vue-next-rx/blob/main/README.md) carefully and find out if the functionality is already covered, maybe by an individual configuration.
111 | - Perform a [search](https://github.com/NOPR9D/vue-next-rxissues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
112 | - Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.
113 |
114 |
115 | #### How Do I Submit a Good Enhancement Suggestion?
116 |
117 | Enhancement suggestions are tracked as [GitHub issues](https://github.com/NOPR9D/vue-next-rxissues).
118 |
119 | - Use a **clear and descriptive title** for the issue to identify the suggestion.
120 | - Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
121 | - **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
122 | - You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux.
123 | - **Explain why this enhancement would be useful** to most Vue next rx users. You may also want to point out the other projects that solved it better and which could serve as inspiration.
124 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2020-present Boucham Amine
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-next-rx
2 |
3 |
4 |
5 |
6 |
7 | ### [RxJS v7](https://github.com/ReactiveX/rxjs) integration for [Vue next]()
8 |
9 |
10 |
11 | 
12 | 
13 |
14 |
15 |
16 | > **NOTE**
17 | >
18 | > - vue-next-rx only works with RxJS v6+ by default. If you want to keep using RxJS v5 style code, install `rxjs-compat`.
19 |
20 | ---
21 |
22 | # Installation
23 |
24 | #### NPM + ES2015 or more
25 |
26 | **`rxjs` is required as a peer dependency.**
27 |
28 | ```bash
29 | npm install vue @nopr3d/vue-next-rx rxjs --save
30 | ```
31 |
32 | ```js
33 | import Vue from "vue";
34 | import VueNextRx from "@nopr3d/vue-next-rx";
35 |
36 | Vue.use(VueNextRx);
37 | ```
38 |
39 |
40 |
41 | When bundling via webpack, `dist/vue-next-rx.esm.js` is used by default. It imports the minimal amount of Rx operators and ensures small bundle sizes.
42 |
43 | To use in a browser environment, use the UMD build `dist/vue-next-rx.js`. When in a browser environment, the UMD build assumes `window.rxjs` to be already present, so make sure to include `vue-next-rx.js` after Vue.js and RxJS. It also installs itself automatically if `window.Vue` is present.
44 |
45 | Example:
46 |
47 | ```html
48 |
49 |
50 |
51 |
205 | ```
206 |
207 | ---
208 |
209 |
210 |
211 | # Other API Methods
212 |
213 |
214 |
215 | ## `$watchAsObservable(expOrFn, [options])`
216 |
217 | This is a prototype method added to instances. You can use it to create an observable from a Data. The emitted value is in the format of `{ newValue, oldValue }`:
218 |
219 | ```js
220 | import { ref } from "@nopr3d/vue-next-rx";
221 |
222 | export default defineComponent({
223 | name: "Home",
224 | setup() {
225 | const msg = ref("Old Message");
226 | setTimeout(() => (msg.value = "New message incomming !"), 1000);
227 | return { msg };
228 | },
229 | subscriptions() {
230 | return {
231 | oldMsg: this.$watchAsObservable("msg").pipe(pluck("oldValue")),
232 | };
233 | },
234 | });
235 | ```
236 |
237 | ```html
238 |
239 |
240 |
{{ msg }}
241 |
242 |
{{oldMsg}}
243 |
244 | ```
245 |
246 | ---
247 |
248 | ## `$subscribeTo(observable, next, error, complete)`
249 |
250 | This is a prototype method added to instances. You can use it to subscribe to an observable, but let VueNextRx manage the dispose/unsubscribe.
251 |
252 | ```js
253 | import { interval } from "rxjs";
254 |
255 | const vm = new Vue({
256 | mounted() {
257 | this.$subscribeTo(interval(1000), function (count) {
258 | console.log(count);
259 | });
260 | },
261 | });
262 | ```
263 |
264 | ## `$fromDOMEvent(selector, event)`
265 |
266 | This is a prototype method added to instances. Use it to create an observable from DOM events within the instances' element. This is similar to `Rx.Observable.fromEvent`, but usable inside the `subscriptions` function even before the DOM is actually rendered.
267 |
268 | `selector` is for finding descendant nodes under the component root element, if you want to listen to events from root element itself, pass `null` as first argument.
269 |
270 | ```js
271 | import { pluck } from "rxjs/operators";
272 |
273 | const vm = new Vue({
274 | subscriptions() {
275 | return {
276 | inputValue: this.$fromDOMEvent("input", "keyup").pipe(
277 | pluck("target", "value")
278 | ),
279 | };
280 | },
281 | });
282 | ```
283 |
284 | ```html
285 |
286 |
{{inputValue}}
287 | ```
288 |
289 | ---
290 |
291 | ## `$createObservableMethod(methodName)`
292 |
293 | Convert function calls to observable sequence which emits the call arguments.
294 |
295 | This is a prototype method added to instances. Use it to create a shared hot observable from a function name. The function will be assigned as a vm method.
296 |
297 | ```html
298 |
299 | ```
300 |
301 | ```js
302 | const vm = new Vue({
303 | subscriptions() {
304 | return {
305 | // requires `share` operator
306 | formData: this.$createObservableMethod("submitHandler"),
307 | };
308 | },
309 | });
310 | ```
311 |
312 | You can use the `observableMethods` option to make it more declarative:
313 |
314 | ```js
315 | new Vue({
316 | observableMethods: {
317 | submitHandler: "submitHandler$",
318 | // or with Array shothand: ['submitHandler']
319 | },
320 | });
321 | ```
322 |
323 | The above will automatically create two things on the instance:
324 |
325 | 1. A `submitHandler` method which can be bound to in template with `v-on`;
326 | 2. A `submitHandler$` observable which will be the stream emitting calls to `submitHandler`.
327 |
328 | [example](https://github.com/NOPR9D/vue-next-rx/blob/main/example/createObservableMethod.html)
329 |
330 | ---
331 |
332 | ## Example
333 |
334 | See `/examples` for some simple examples.
335 |
336 |
337 |
338 | ---
339 |
340 | ## Test
341 |
342 | Test look goods, feel free to open an issue !
343 |
344 | 
345 |
346 | ---
347 |
348 | ### Contributors
349 |
350 |