@rallie/vue
Advanced tools
Comparing version 0.6.0 to 0.6.1
export * from './hooks'; | ||
export * from './mixins'; |
@@ -38,2 +38,78 @@ import { ref, onBeforeUnmount, onBeforeMount } from 'vue'; | ||
export { eventsHook, methodsHook, stateHook }; | ||
var stateMixin = function (app) { return function (mapStateToComputed) { | ||
var unwatchState = null; | ||
var computed = {}; | ||
var mappedState = mapStateToComputed(app.state); | ||
var dataKey = "rallie-state-".concat(app.name); | ||
Object.keys(mappedState).forEach(function (key) { | ||
computed[key] = function () { | ||
return this[dataKey][key]; | ||
}; | ||
}); | ||
return { | ||
data: function () { | ||
var _a; | ||
var result = (_a = {}, | ||
_a[dataKey] = mappedState, | ||
_a); | ||
return result; | ||
}, | ||
computed: computed, | ||
created: function () { | ||
var _this = this; | ||
unwatchState = app.watchState(mapStateToComputed).do(function (value) { | ||
_this[dataKey] = value; | ||
}); | ||
}, | ||
beforeDestroy: function () { | ||
unwatchState(); | ||
}, | ||
beforeUnmount: function () { | ||
unwatchState(); | ||
} | ||
}; | ||
}; }; | ||
var eventsMixin = function (app) { return function (events) { | ||
var offEvents = null; | ||
return { | ||
methods: events, | ||
created: function () { | ||
var _this = this; | ||
var _events = {}; | ||
Object.entries(events).forEach(function (_a) { | ||
var key = _a[0], Fn = _a[1]; | ||
_events[key] = Fn.bind(_this); | ||
}); | ||
offEvents = app.listenEvents(_events); | ||
}, | ||
beforeDestroy: function () { | ||
offEvents(); | ||
}, | ||
beforeUnmount: function () { | ||
offEvents(); | ||
} | ||
}; | ||
}; }; | ||
var methodsMixin = function (app) { return function (methods) { | ||
var offMethods = null; | ||
return { | ||
methods: methods, | ||
created: function () { | ||
var _this = this; | ||
var _methods = {}; | ||
Object.entries(methods).forEach(function (_a) { | ||
var key = _a[0], Fn = _a[1]; | ||
_methods[key] = Fn.bind(_this); | ||
}); | ||
offMethods = app.addMethods(_methods); | ||
}, | ||
beforeDestroy: function () { | ||
offMethods(); | ||
}, | ||
beforeUnmount: function () { | ||
offMethods(); | ||
} | ||
}; | ||
}; }; | ||
export { eventsHook, eventsMixin, methodsHook, methodsMixin, stateHook, stateMixin }; |
@@ -42,5 +42,84 @@ (function (global, factory) { | ||
var stateMixin = function (app) { return function (mapStateToComputed) { | ||
var unwatchState = null; | ||
var computed = {}; | ||
var mappedState = mapStateToComputed(app.state); | ||
var dataKey = "rallie-state-".concat(app.name); | ||
Object.keys(mappedState).forEach(function (key) { | ||
computed[key] = function () { | ||
return this[dataKey][key]; | ||
}; | ||
}); | ||
return { | ||
data: function () { | ||
var _a; | ||
var result = (_a = {}, | ||
_a[dataKey] = mappedState, | ||
_a); | ||
return result; | ||
}, | ||
computed: computed, | ||
created: function () { | ||
var _this = this; | ||
unwatchState = app.watchState(mapStateToComputed).do(function (value) { | ||
_this[dataKey] = value; | ||
}); | ||
}, | ||
beforeDestroy: function () { | ||
unwatchState(); | ||
}, | ||
beforeUnmount: function () { | ||
unwatchState(); | ||
} | ||
}; | ||
}; }; | ||
var eventsMixin = function (app) { return function (events) { | ||
var offEvents = null; | ||
return { | ||
methods: events, | ||
created: function () { | ||
var _this = this; | ||
var _events = {}; | ||
Object.entries(events).forEach(function (_a) { | ||
var key = _a[0], Fn = _a[1]; | ||
_events[key] = Fn.bind(_this); | ||
}); | ||
offEvents = app.listenEvents(_events); | ||
}, | ||
beforeDestroy: function () { | ||
offEvents(); | ||
}, | ||
beforeUnmount: function () { | ||
offEvents(); | ||
} | ||
}; | ||
}; }; | ||
var methodsMixin = function (app) { return function (methods) { | ||
var offMethods = null; | ||
return { | ||
methods: methods, | ||
created: function () { | ||
var _this = this; | ||
var _methods = {}; | ||
Object.entries(methods).forEach(function (_a) { | ||
var key = _a[0], Fn = _a[1]; | ||
_methods[key] = Fn.bind(_this); | ||
}); | ||
offMethods = app.addMethods(_methods); | ||
}, | ||
beforeDestroy: function () { | ||
offMethods(); | ||
}, | ||
beforeUnmount: function () { | ||
offMethods(); | ||
} | ||
}; | ||
}; }; | ||
exports.eventsHook = eventsHook; | ||
exports.eventsMixin = eventsMixin; | ||
exports.methodsHook = methodsHook; | ||
exports.methodsMixin = methodsMixin; | ||
exports.stateHook = stateHook; | ||
exports.stateMixin = stateMixin; | ||
@@ -47,0 +126,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
{ | ||
"name": "@rallie/vue", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "vue binding for rallie", | ||
@@ -25,10 +25,10 @@ "author": "runnan <1608272694@qq.com>", | ||
"peerDependencies": { | ||
"rallie": ">=0.5.3", | ||
"rallie": "^0.6.0", | ||
"vue": ">=3.2.6" | ||
}, | ||
"devDependencies": { | ||
"@rallie/core": "^0.6.0", | ||
"rallie": "^0.6.0" | ||
"@rallie/core": "^0.6.1", | ||
"rallie": "^0.6.1" | ||
}, | ||
"gitHead": "8be5247aeedca969023dd6d3854b4075abc614a1" | ||
"gitHead": "97ad8a63ef22f61aeb42404288da57c00b3f0cd3" | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
16005
10
424
1