@rallie/vue
Advanced tools
Comparing version 0.7.0 to 0.7.1
import { UnwrapRef } from 'vue'; | ||
import type { App, Connector, CallbackType } from 'rallie'; | ||
export declare function stateHook<State extends object>(app: App<State> | Connector<State>): <P>(getter: (_state: State) => P) => import("vue").Ref<UnwrapRef<P>>; | ||
export declare function eventsHook<Events extends Record<string, CallbackType>>(app: App | Connector): (events: Partial<Events>) => void; | ||
export declare function methodsHook<Methods extends Record<string, CallbackType>>(app: App): (events: Partial<Methods>) => void; | ||
import type { App, Connector } from 'rallie'; | ||
export declare function useRallieState<T extends App | Connector, U>(app: T, getter: (state: T['state']) => U): import("vue").Ref<UnwrapRef<U>>; | ||
export declare function useRallieEvents<T extends App | Connector>(app: T, events: Partial<T['events']>): void; | ||
export declare function useRallieMethods<T extends App>(app: T, methods: Partial<T['methods']>): void; |
@@ -1,39 +0,36 @@ | ||
import { ref, onBeforeUnmount, onBeforeMount } from 'vue'; | ||
import { ref, onBeforeMount, onBeforeUnmount } from 'vue'; | ||
function stateHook(app) { | ||
return function (getter) { | ||
var stateRef = ref(getter(app.state)); | ||
var unwatch = app.watchState(getter).do(function (value) { | ||
function useRallieState(app, getter) { | ||
var stateRef = ref(getter(app.state)); | ||
var unwatch = null; | ||
onBeforeMount(function () { | ||
unwatch = app.watchState(getter).do(function (value) { | ||
stateRef.value = value; | ||
}); | ||
onBeforeUnmount(function () { | ||
unwatch(); | ||
}); | ||
return stateRef; | ||
}; | ||
}); | ||
onBeforeUnmount(function () { | ||
unwatch(); | ||
}); | ||
return stateRef; | ||
} | ||
function eventsHook(app) { | ||
return function (events) { | ||
var off = null; | ||
onBeforeMount(function () { | ||
off = app.listenEvents(events); | ||
}); | ||
onBeforeUnmount(function () { | ||
off(); | ||
}); | ||
}; | ||
function useRallieEvents(app, events) { | ||
var off = null; | ||
onBeforeMount(function () { | ||
off = app.listenEvents(events); | ||
}); | ||
onBeforeUnmount(function () { | ||
off(); | ||
}); | ||
} | ||
function methodsHook(app) { | ||
return function (events) { | ||
var off = null; | ||
onBeforeMount(function () { | ||
off = app.addMethods(events); | ||
}); | ||
onBeforeUnmount(function () { | ||
off(); | ||
}); | ||
}; | ||
function useRallieMethods(app, methods) { | ||
var off = null; | ||
onBeforeMount(function () { | ||
off = app.addMethods(methods); | ||
}); | ||
onBeforeUnmount(function () { | ||
off(); | ||
}); | ||
} | ||
var stateMixin = function (app) { return function (mapStateToComputed) { | ||
function mixinRallieState(app, mapStateToComputed) { | ||
var unwatchState = null; | ||
@@ -57,3 +54,3 @@ var computed = {}; | ||
computed: computed, | ||
created: function () { | ||
mounted: function () { | ||
var _this = this; | ||
@@ -71,8 +68,8 @@ unwatchState = app.watchState(mapStateToComputed).do(function (value) { | ||
}; | ||
}; }; | ||
var eventsMixin = function (app) { return function (events) { | ||
} | ||
function mixinRallieEvents(app, events) { | ||
var offEvents = null; | ||
return { | ||
methods: events, | ||
created: function () { | ||
mounted: function () { | ||
var _this = this; | ||
@@ -93,4 +90,4 @@ var _events = {}; | ||
}; | ||
}; }; | ||
var methodsMixin = function (app) { return function (methods) { | ||
} | ||
function mixinRallieMethods(app, methods) { | ||
var offMethods = null; | ||
@@ -115,4 +112,4 @@ return { | ||
}; | ||
}; }; | ||
} | ||
export { eventsHook, eventsMixin, methodsHook, methodsMixin, stateHook, stateMixin }; | ||
export { mixinRallieEvents, mixinRallieMethods, mixinRallieState, useRallieEvents, useRallieMethods, useRallieState }; |
@@ -7,38 +7,35 @@ (function (global, factory) { | ||
function stateHook(app) { | ||
return function (getter) { | ||
var stateRef = vue.ref(getter(app.state)); | ||
var unwatch = app.watchState(getter).do(function (value) { | ||
function useRallieState(app, getter) { | ||
var stateRef = vue.ref(getter(app.state)); | ||
var unwatch = null; | ||
vue.onBeforeMount(function () { | ||
unwatch = app.watchState(getter).do(function (value) { | ||
stateRef.value = value; | ||
}); | ||
vue.onBeforeUnmount(function () { | ||
unwatch(); | ||
}); | ||
return stateRef; | ||
}; | ||
}); | ||
vue.onBeforeUnmount(function () { | ||
unwatch(); | ||
}); | ||
return stateRef; | ||
} | ||
function eventsHook(app) { | ||
return function (events) { | ||
var off = null; | ||
vue.onBeforeMount(function () { | ||
off = app.listenEvents(events); | ||
}); | ||
vue.onBeforeUnmount(function () { | ||
off(); | ||
}); | ||
}; | ||
function useRallieEvents(app, events) { | ||
var off = null; | ||
vue.onBeforeMount(function () { | ||
off = app.listenEvents(events); | ||
}); | ||
vue.onBeforeUnmount(function () { | ||
off(); | ||
}); | ||
} | ||
function methodsHook(app) { | ||
return function (events) { | ||
var off = null; | ||
vue.onBeforeMount(function () { | ||
off = app.addMethods(events); | ||
}); | ||
vue.onBeforeUnmount(function () { | ||
off(); | ||
}); | ||
}; | ||
function useRallieMethods(app, methods) { | ||
var off = null; | ||
vue.onBeforeMount(function () { | ||
off = app.addMethods(methods); | ||
}); | ||
vue.onBeforeUnmount(function () { | ||
off(); | ||
}); | ||
} | ||
var stateMixin = function (app) { return function (mapStateToComputed) { | ||
function mixinRallieState(app, mapStateToComputed) { | ||
var unwatchState = null; | ||
@@ -62,3 +59,3 @@ var computed = {}; | ||
computed: computed, | ||
created: function () { | ||
mounted: function () { | ||
var _this = this; | ||
@@ -76,8 +73,8 @@ unwatchState = app.watchState(mapStateToComputed).do(function (value) { | ||
}; | ||
}; }; | ||
var eventsMixin = function (app) { return function (events) { | ||
} | ||
function mixinRallieEvents(app, events) { | ||
var offEvents = null; | ||
return { | ||
methods: events, | ||
created: function () { | ||
mounted: function () { | ||
var _this = this; | ||
@@ -98,4 +95,4 @@ var _events = {}; | ||
}; | ||
}; }; | ||
var methodsMixin = function (app) { return function (methods) { | ||
} | ||
function mixinRallieMethods(app, methods) { | ||
var offMethods = null; | ||
@@ -120,10 +117,10 @@ return { | ||
}; | ||
}; }; | ||
} | ||
exports.eventsHook = eventsHook; | ||
exports.eventsMixin = eventsMixin; | ||
exports.methodsHook = methodsHook; | ||
exports.methodsMixin = methodsMixin; | ||
exports.stateHook = stateHook; | ||
exports.stateMixin = stateMixin; | ||
exports.mixinRallieEvents = mixinRallieEvents; | ||
exports.mixinRallieMethods = mixinRallieMethods; | ||
exports.mixinRallieState = mixinRallieState; | ||
exports.useRallieEvents = useRallieEvents; | ||
exports.useRallieMethods = useRallieMethods; | ||
exports.useRallieState = useRallieState; | ||
@@ -130,0 +127,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -1,2 +0,2 @@ | ||
var stateMixin = function (app) { return function (mapStateToComputed) { | ||
function mixinRallieState(app, mapStateToComputed) { | ||
var unwatchState = null; | ||
@@ -20,3 +20,3 @@ var computed = {}; | ||
computed: computed, | ||
created: function () { | ||
mounted: function () { | ||
var _this = this; | ||
@@ -34,8 +34,8 @@ unwatchState = app.watchState(mapStateToComputed).do(function (value) { | ||
}; | ||
}; }; | ||
var eventsMixin = function (app) { return function (events) { | ||
} | ||
function mixinRallieEvents(app, events) { | ||
var offEvents = null; | ||
return { | ||
methods: events, | ||
created: function () { | ||
mounted: function () { | ||
var _this = this; | ||
@@ -56,4 +56,4 @@ var _events = {}; | ||
}; | ||
}; }; | ||
var methodsMixin = function (app) { return function (methods) { | ||
} | ||
function mixinRallieMethods(app, methods) { | ||
var offMethods = null; | ||
@@ -78,4 +78,4 @@ return { | ||
}; | ||
}; }; | ||
} | ||
export { eventsMixin, methodsMixin, stateMixin }; | ||
export { mixinRallieEvents, mixinRallieMethods, mixinRallieState }; |
@@ -7,3 +7,3 @@ (function (global, factory) { | ||
var stateMixin = function (app) { return function (mapStateToComputed) { | ||
function mixinRallieState(app, mapStateToComputed) { | ||
var unwatchState = null; | ||
@@ -27,3 +27,3 @@ var computed = {}; | ||
computed: computed, | ||
created: function () { | ||
mounted: function () { | ||
var _this = this; | ||
@@ -41,8 +41,8 @@ unwatchState = app.watchState(mapStateToComputed).do(function (value) { | ||
}; | ||
}; }; | ||
var eventsMixin = function (app) { return function (events) { | ||
} | ||
function mixinRallieEvents(app, events) { | ||
var offEvents = null; | ||
return { | ||
methods: events, | ||
created: function () { | ||
mounted: function () { | ||
var _this = this; | ||
@@ -63,4 +63,4 @@ var _events = {}; | ||
}; | ||
}; }; | ||
var methodsMixin = function (app) { return function (methods) { | ||
} | ||
function mixinRallieMethods(app, methods) { | ||
var offMethods = null; | ||
@@ -85,7 +85,7 @@ return { | ||
}; | ||
}; }; | ||
} | ||
exports.eventsMixin = eventsMixin; | ||
exports.methodsMixin = methodsMixin; | ||
exports.stateMixin = stateMixin; | ||
exports.mixinRallieEvents = mixinRallieEvents; | ||
exports.mixinRallieMethods = mixinRallieMethods; | ||
exports.mixinRallieState = mixinRallieState; | ||
@@ -92,0 +92,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
import { App, Connector } from 'rallie'; | ||
import type { CallbackType } from 'rallie'; | ||
export declare const stateMixin: <State extends {}>(app: App<State, {}, {}> | Connector<State, {}, {}>) => <P>(mapStateToComputed: (state: State) => P) => { | ||
export declare function mixinRallieState<T extends App | Connector, U>(app: T, mapStateToComputed: (state: T['state']) => U): { | ||
data(): { | ||
[x: string]: P; | ||
[x: string]: U; | ||
}; | ||
computed: {}; | ||
created(): void; | ||
mounted(): void; | ||
beforeDestroy(): void; | ||
beforeUnmount(): void; | ||
}; | ||
export declare const eventsMixin: <Events extends Record<string, CallbackType>>(app: App<{}, Events, {}> | Connector<{}, Events, {}>) => (events: Partial<Events>) => { | ||
methods: Partial<Events>; | ||
created(): void; | ||
export declare function mixinRallieEvents<T extends App | Connector>(app: T, events: Partial<T['events']>): { | ||
methods: Partial<T["events"]>; | ||
mounted(): void; | ||
beforeDestroy(): void; | ||
beforeUnmount(): void; | ||
}; | ||
export declare const methodsMixin: <Methods extends Record<string, CallbackType>>(app: App<{}, {}, Methods>) => (methods: Partial<Methods>) => { | ||
methods: Partial<Methods>; | ||
export declare function mixinRallieMethods<T extends App>(app: T, methods: Partial<T['methods']>): { | ||
methods: Partial<T["methods"]>; | ||
created(): void; | ||
@@ -21,0 +20,0 @@ beforeDestroy(): void; |
{ | ||
"name": "@rallie/vue", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "vue binding for rallie", | ||
@@ -29,5 +29,5 @@ "author": "runnan <1608272694@qq.com>", | ||
"devDependencies": { | ||
"rallie": "^0.7.0" | ||
"rallie": "^0.7.1" | ||
}, | ||
"gitHead": "292fc1f3a6aa339654d9dc1d8fe593d0c5012737" | ||
"gitHead": "dade5d8a9a43fbf0f6c3412d54937f7174de5ddd" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15496
417