@vueuse/rxjs
Advanced tools
Comparing version 11.3.0 to 12.0.0-beta.1
import { MaybeRef, MultiWatchSources, MapSources, MapOldSources } from '@vueuse/shared'; | ||
import { ObservableInput, Observable, NextObserver, BehaviorSubject, Subject, Unsubscribable } from 'rxjs'; | ||
import { Ref, WatchOptions, WatchStopHandle, WatchSource } from 'vue-demi'; | ||
import { Ref, WatchOptions, WatchStopHandle, WatchSource } from 'vue'; | ||
@@ -5,0 +5,0 @@ declare function from<T>(value: ObservableInput<T> | Ref<T>, watchOptions?: WatchOptions): Observable<T>; |
@@ -1,141 +0,14 @@ | ||
var _VueDemiGlobal = typeof globalThis !== 'undefined' | ||
? globalThis | ||
: typeof global !== 'undefined' | ||
? global | ||
: typeof self !== 'undefined' | ||
? self | ||
: this | ||
var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) { | ||
if (VueDemi.install) { | ||
return VueDemi | ||
} | ||
if (!Vue) { | ||
console.error('[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.') | ||
return VueDemi | ||
} | ||
// Vue 2.7 | ||
if (Vue.version.slice(0, 4) === '2.7.') { | ||
for (var key in Vue) { | ||
VueDemi[key] = Vue[key] | ||
} | ||
VueDemi.isVue2 = true | ||
VueDemi.isVue3 = false | ||
VueDemi.install = function () {} | ||
VueDemi.Vue = Vue | ||
VueDemi.Vue2 = Vue | ||
VueDemi.version = Vue.version | ||
VueDemi.warn = Vue.util.warn | ||
VueDemi.hasInjectionContext = function() { | ||
return !!VueDemi.getCurrentInstance() | ||
} | ||
function createApp(rootComponent, rootProps) { | ||
var vm | ||
var provide = {} | ||
var app = { | ||
config: Vue.config, | ||
use: Vue.use.bind(Vue), | ||
mixin: Vue.mixin.bind(Vue), | ||
component: Vue.component.bind(Vue), | ||
provide: function (key, value) { | ||
provide[key] = value | ||
return this | ||
}, | ||
directive: function (name, dir) { | ||
if (dir) { | ||
Vue.directive(name, dir) | ||
return app | ||
} else { | ||
return Vue.directive(name) | ||
} | ||
}, | ||
mount: function (el, hydrating) { | ||
if (!vm) { | ||
vm = new Vue(Object.assign({ propsData: rootProps }, rootComponent, { provide: Object.assign(provide, rootComponent.provide) })) | ||
vm.$mount(el, hydrating) | ||
return vm | ||
} else { | ||
return vm | ||
} | ||
}, | ||
unmount: function () { | ||
if (vm) { | ||
vm.$destroy() | ||
vm = undefined | ||
} | ||
}, | ||
} | ||
return app | ||
} | ||
VueDemi.createApp = createApp | ||
} | ||
// Vue 2.6.x | ||
else if (Vue.version.slice(0, 2) === '2.') { | ||
if (VueCompositionAPI) { | ||
for (var key in VueCompositionAPI) { | ||
VueDemi[key] = VueCompositionAPI[key] | ||
} | ||
VueDemi.isVue2 = true | ||
VueDemi.isVue3 = false | ||
VueDemi.install = function () {} | ||
VueDemi.Vue = Vue | ||
VueDemi.Vue2 = Vue | ||
VueDemi.version = Vue.version | ||
VueDemi.hasInjectionContext = function() { | ||
return !!VueDemi.getCurrentInstance() | ||
} | ||
} else { | ||
console.error('[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.') | ||
} | ||
} | ||
// Vue 3 | ||
else if (Vue.version.slice(0, 2) === '3.') { | ||
for (var key in Vue) { | ||
VueDemi[key] = Vue[key] | ||
} | ||
VueDemi.isVue2 = false | ||
VueDemi.isVue3 = true | ||
VueDemi.install = function () {} | ||
VueDemi.Vue = Vue | ||
VueDemi.Vue2 = undefined | ||
VueDemi.version = Vue.version | ||
VueDemi.set = function (target, key, val) { | ||
if (Array.isArray(target)) { | ||
target.length = Math.max(target.length, key) | ||
target.splice(key, 1, val) | ||
return val | ||
} | ||
target[key] = val | ||
return val | ||
} | ||
VueDemi.del = function (target, key) { | ||
if (Array.isArray(target)) { | ||
target.splice(key, 1) | ||
return | ||
} | ||
delete target[key] | ||
} | ||
} else { | ||
console.error('[vue-demi] Vue version ' + Vue.version + ' is unsupported.') | ||
} | ||
return VueDemi | ||
})( | ||
(_VueDemiGlobal.VueDemi = _VueDemiGlobal.VueDemi || (typeof VueDemi !== 'undefined' ? VueDemi : {})), | ||
_VueDemiGlobal.Vue || (typeof Vue !== 'undefined' ? Vue : undefined), | ||
_VueDemiGlobal.VueCompositionAPI || (typeof VueCompositionAPI !== 'undefined' ? VueCompositionAPI : undefined) | ||
); | ||
; | ||
;(function (exports, rxjs, vueDemi, shared) { | ||
(function (exports, rxjs, vue, shared) { | ||
'use strict'; | ||
function from(value, watchOptions) { | ||
if (vueDemi.isRef(value)) | ||
return new rxjs.Observable((subscriber) => vueDemi.watch(value, (val) => subscriber.next(val), watchOptions)); | ||
if (vue.isRef(value)) | ||
return new rxjs.Observable((subscriber) => vue.watch(value, (val) => subscriber.next(val), watchOptions)); | ||
return rxjs.from(value); | ||
} | ||
function fromEvent(value, event) { | ||
if (vueDemi.isRef(value)) { | ||
if (vue.isRef(value)) { | ||
return new rxjs.Observable((subscriber) => { | ||
let innerSub; | ||
return vueDemi.watch(value, (element) => { | ||
return vue.watch(value, (element) => { | ||
innerSub == null ? void 0 : innerSub.unsubscribe(); | ||
@@ -166,4 +39,4 @@ if (element instanceof HTMLElement) { | ||
}); | ||
const obsRef = vueDemi.shallowRef(options == null ? void 0 : options.initialValue); | ||
vueDemi.watch(source, (value, oldValue, onCleanup) => { | ||
const obsRef = vue.shallowRef(options == null ? void 0 : options.initialValue); | ||
vue.watch(source, (value, oldValue, onCleanup) => { | ||
subscription == null ? void 0 : subscription.unsubscribe(); | ||
@@ -192,7 +65,7 @@ if (typeof value !== "undefined" && value !== null) { | ||
}); | ||
return vueDemi.readonly(obsRef); | ||
return vue.readonly(obsRef); | ||
} | ||
function useObservable(observable, options) { | ||
const value = vueDemi.ref(options == null ? void 0 : options.initialValue); | ||
const value = vue.ref(options == null ? void 0 : options.initialValue); | ||
const subscription = observable.subscribe({ | ||
@@ -209,3 +82,3 @@ next: (val) => value.value = val, | ||
function useSubject(subject, options) { | ||
const value = vueDemi.ref( | ||
const value = vue.ref( | ||
subject instanceof rxjs.BehaviorSubject ? subject.value : void 0 | ||
@@ -219,3 +92,3 @@ ); | ||
}); | ||
vueDemi.watch(value, (nextValue) => { | ||
vue.watch(value, (nextValue) => { | ||
subject.next(nextValue); | ||
@@ -241,3 +114,3 @@ }); | ||
}); | ||
return vueDemi.watch(source, (value, oldValue, onCleanup) => { | ||
return vue.watch(source, (value, oldValue, onCleanup) => { | ||
subscription == null ? void 0 : subscription.unsubscribe(); | ||
@@ -266,2 +139,2 @@ if (typeof value !== "undefined" && value !== null) { | ||
})(this.VueUse = this.VueUse || {}, rxjs, VueDemi, VueUse); | ||
})(this.VueUse = this.VueUse || {}, rxjs, Vue, VueUse); |
@@ -1,1 +0,1 @@ | ||
var _VueDemiGlobal=typeof globalThis<"u"?globalThis:typeof global<"u"?global:typeof self<"u"?self:this,VueDemi=function(n,e,l){if(n.install)return n;if(!e)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),n;if(e.version.slice(0,4)==="2.7."){let c=function(f,d){var a,h={},O={config:e.config,use:e.use.bind(e),mixin:e.mixin.bind(e),component:e.component.bind(e),provide:function(v,r){return h[v]=r,this},directive:function(v,r){return r?(e.directive(v,r),O):e.directive(v)},mount:function(v,r){return a||(a=new e(Object.assign({propsData:d},f,{provide:Object.assign(h,f.provide)})),a.$mount(v,r),a)},unmount:function(){a&&(a.$destroy(),a=void 0)}};return O};var S=c;for(var u in e)n[u]=e[u];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=e,n.Vue2=e,n.version=e.version,n.warn=e.util.warn,n.hasInjectionContext=function(){return!!n.getCurrentInstance()},n.createApp=c}else if(e.version.slice(0,2)==="2.")if(l){for(var u in l)n[u]=l[u];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=e,n.Vue2=e,n.version=e.version,n.hasInjectionContext=function(){return!!n.getCurrentInstance()}}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(e.version.slice(0,2)==="3."){for(var u in e)n[u]=e[u];n.isVue2=!1,n.isVue3=!0,n.install=function(){},n.Vue=e,n.Vue2=void 0,n.version=e.version,n.set=function(c,f,d){return Array.isArray(c)?(c.length=Math.max(c.length,f),c.splice(f,1,d),d):(c[f]=d,d)},n.del=function(c,f){if(Array.isArray(c)){c.splice(f,1);return}delete c[f]}}else console.error("[vue-demi] Vue version "+e.version+" is unsupported.");return n}(_VueDemiGlobal.VueDemi=_VueDemiGlobal.VueDemi||(typeof VueDemi<"u"?VueDemi:{}),_VueDemiGlobal.Vue||(typeof Vue<"u"?Vue:void 0),_VueDemiGlobal.VueCompositionAPI||(typeof VueCompositionAPI<"u"?VueCompositionAPI:void 0));(function(n,e,l,u){"use strict";function S(r,i){return l.isRef(r)?new e.Observable(o=>l.watch(r,s=>o.next(s),i)):e.from(r)}function c(r,i){return l.isRef(r)?new e.Observable(o=>{let s;return l.watch(r,t=>{s?.unsubscribe(),t instanceof HTMLElement&&(s=e.fromEvent(t,i).subscribe(o),o.add(s))},{immediate:!0})}):e.fromEvent(r,i)}function f(r){return{next:i=>{r.value=i}}}function d(r,i,o,s){let t;u.tryOnScopeDispose(()=>{t?.unsubscribe(),t=void 0});const b=l.shallowRef(o?.initialValue);return l.watch(r,(p,w,E)=>{t?.unsubscribe(),typeof p<"u"&&p!==null?t=i(p,w,E).subscribe({error:y=>{var A;(A=o?.onError)==null||A.call(o,y)},complete:()=>{var y;(y=o?.onComplete)==null||y.call(o)},next:y=>{b.value=y}}):t=void 0},{immediate:!0,...s}),l.readonly(b)}function a(r,i){const o=l.ref(i?.initialValue),s=r.subscribe({next:t=>o.value=t,error:i?.onError});return u.tryOnScopeDispose(()=>{s.unsubscribe()}),o}function h(r,i){const o=l.ref(r instanceof e.BehaviorSubject?r.value:void 0),s=r.subscribe({next(t){o.value=t},error:i?.onError});return l.watch(o,t=>{r.next(t)}),u.tryOnScopeDispose(()=>{s.unsubscribe()}),o}function O(r){u.tryOnScopeDispose(()=>{r.unsubscribe()})}function v(r,i,o,s,t){let b;return u.tryOnScopeDispose(()=>{b?.unsubscribe(),b=void 0}),l.watch(r,(p,w,E)=>{b?.unsubscribe(),typeof p<"u"&&p!==null?b=i(p,w,E).subscribe({next:o,error:s?.onError,complete:s?.onComplete}):b=void 0},t)}n.from=S,n.fromEvent=c,n.toObserver=f,n.useExtractedObservable=d,n.useObservable=a,n.useSubject=h,n.useSubscription=O,n.watchExtractedObservable=v})(this.VueUse=this.VueUse||{},rxjs,VueDemi,VueUse); | ||
(function(o,c,i,a){"use strict";function m(e,r){return i.isRef(e)?new c.Observable(n=>i.watch(e,l=>n.next(l),r)):c.from(e)}function E(e,r){return i.isRef(e)?new c.Observable(n=>{let l;return i.watch(e,u=>{l?.unsubscribe(),u instanceof HTMLElement&&(l=c.fromEvent(u,r).subscribe(n),n.add(l))},{immediate:!0})}):c.fromEvent(e,r)}function O(e){return{next:r=>{e.value=r}}}function S(e,r,n,l){let u;a.tryOnScopeDispose(()=>{u?.unsubscribe(),u=void 0});const t=i.shallowRef(n?.initialValue);return i.watch(e,(b,f,d)=>{u?.unsubscribe(),typeof b<"u"&&b!==null?u=r(b,f,d).subscribe({error:s=>{var v;(v=n?.onError)==null||v.call(n,s)},complete:()=>{var s;(s=n?.onComplete)==null||s.call(n)},next:s=>{t.value=s}}):u=void 0},{immediate:!0,...l}),i.readonly(t)}function w(e,r){const n=i.ref(r?.initialValue),l=e.subscribe({next:u=>n.value=u,error:r?.onError});return a.tryOnScopeDispose(()=>{l.unsubscribe()}),n}function y(e,r){const n=i.ref(e instanceof c.BehaviorSubject?e.value:void 0),l=e.subscribe({next(u){n.value=u},error:r?.onError});return i.watch(n,u=>{e.next(u)}),a.tryOnScopeDispose(()=>{l.unsubscribe()}),n}function h(e){a.tryOnScopeDispose(()=>{e.unsubscribe()})}function V(e,r,n,l,u){let t;return a.tryOnScopeDispose(()=>{t?.unsubscribe(),t=void 0}),i.watch(e,(b,f,d)=>{t?.unsubscribe(),typeof b<"u"&&b!==null?t=r(b,f,d).subscribe({next:n,error:l?.onError,complete:l?.onComplete}):t=void 0},u)}o.from=m,o.fromEvent=E,o.toObserver=O,o.useExtractedObservable=S,o.useObservable=w,o.useSubject=y,o.useSubscription=h,o.watchExtractedObservable=V})(this.VueUse=this.VueUse||{},rxjs,Vue,VueUse); |
{ | ||
"name": "@vueuse/rxjs", | ||
"version": "11.3.0", | ||
"version": "12.0.0-beta.1", | ||
"description": "Enables RxJS reactive functions in Vue", | ||
@@ -41,5 +41,5 @@ "author": "Anthony Fu <https://github.com/antfu>", | ||
"dependencies": { | ||
"@vueuse/shared": "11.3.0", | ||
"vue-demi": ">=0.14.10" | ||
"@vueuse/shared": "12.0.0-beta.1", | ||
"vue": "^3.5.13" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
33084
422
1
+ Addedvue@^3.5.13
+ Added@vueuse/shared@12.0.0-beta.1(transitive)
- Removedvue-demi@>=0.14.10
- Removed@vueuse/shared@11.3.0(transitive)
- Removedvue-demi@0.14.10(transitive)
Updated@vueuse/shared@12.0.0-beta.1