├── .babelrc
├── .gitignore
├── LICENSE
├── README.md
├── example
├── index.html
├── main.js
└── webpack.config.js
├── package.json
├── src
├── ActionsObservable.js
└── index.js
└── test
├── jasmine.json
└── test.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015"]
3 | }
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | dist
3 | node_modules
4 | example/bundle.js
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Evan You
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.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # THIS REPOSITORY IS DEPRECATED
2 |
3 | ## vuex-observable
4 |
5 | > Proof of Concept, DO NOT USE YET
6 |
7 | Consume Vuex actions as Observables using RxJS 5, inspired by [redux-observable](https://github.com/redux-observable/redux-observable).
8 |
9 | ## Usage
10 |
11 | ``` js
12 | import Vue from 'vue'
13 | import Vuex from 'vuex'
14 | import { observableAction } from 'vuex-observable'
15 | import 'rxjs/add/operator/delay'
16 |
17 | Vue.use(Vuex)
18 |
19 | const store = new Vuex.Store({
20 | state: {
21 | pinging: false
22 | },
23 | mutations: {
24 | ping: state => state.pinging = true,
25 | pong: state => state.pinging = false
26 | },
27 | actions: {
28 | ping: observableAction((action$, { commit }) => {
29 | action$.subscribe(() => commit('ping'))
30 | action$.delay(1000).subscribe(() => commit('pong'))
31 | })
32 | }
33 | })
34 | ```
35 |
36 | ## TODOs
37 |
38 | - Working with multiple actions as source
39 | - Adaptors
40 | - Cancellation
41 | - HMR support
42 |
--------------------------------------------------------------------------------
/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | vuex observable example
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/example/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Vuex from 'vuex'
3 | import { observableAction } from '../src'
4 | import 'rxjs/add/operator/delay'
5 |
6 | Vue.use(Vuex)
7 |
8 | const store = new Vuex.Store({
9 | state: {
10 | pinging: false
11 | },
12 | mutations: {
13 | ping: state => state.pinging = true,
14 | pong: state => state.pinging = false
15 | },
16 | actions: {
17 | // convert an action into an observableAction
18 | ping: observableAction((action$, { commit }) => {
19 | // first argument will be an observable representing
20 | // the stream for "ping" actions
21 | action$.subscribe(() => commit('ping'))
22 | action$.delay(1000).subscribe(() => commit('pong'))
23 | })
24 | }
25 | })
26 |
27 | new Vue({
28 | store,
29 | el: '#app',
30 | template: `
31 |