spyfu / spyfu-vuex-helpers Goto Github PK
View Code? Open in Web Editor NEWUtility functions for Vuex
Home Page: https://spyfu.com
License: MIT License
Utility functions for Vuex
Home Page: https://spyfu.com
License: MIT License
Thank you for great helpers.
Is it possible to add ability to pass a filter to mapTwoWayState?
Finding the instance in each mutation / getter can be a bit redundant, leaving this here as a potential solution.
// mutations
export default {
// current
foo: findInstanceThen((instance, payload) => {
// ...
}),
// possible new api
...instanceMutations({
foo(instance, payload) {
// ...
},
}),
}
// getters
export default {
// current
foo: state => id => {
const instance = findInstance(state, id) {
// ...
},
// possible new api
...instanceGetters({
foo(instance) {
// ...
},
}),
};
When simpleInstanceSetters
mutations are mapped with vuex mapMutations
, vm's id property is ignored and the mapped mutations expects { id, value }
type payload.
It would be very helpful to add a mapInstanceMutations
helper.
The findInstanceThen
helper should throw a couple warnings in development
instances
arrayid
propertyThe findInstanceThen
helper should accept a config object to modify the instance array name and id property. We should be able to make a custom version of the helper by partially applying the configuration.
import helpers from 'spyfu-vuex-helpers';
const findInstanceThen = helpers.findInstanceThen.bind(null, {
stateKey: 'instances',
instanceKey: 'id',
});
The above is a bit clunky, but it gets the idea across. We should come up with a cleaner api for customizing the helper.
While working, it's easy to forget that mapTwoWayState
does not share the same API as Vuex's mapState
function. The following should throw a more descriptive error.
export default {
computed: {
...mapTwoWayState('someNamespace', [
'whatever',
]),
},
};
Currently, no error is thrown by our helper, and Vue will be unable to access the desired state. This warning will be logged, but it doesn't really help describe why the error is happening.
[Vue warn]: Property or method "whatever" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
Applying partial configuration to findInstanceThen
causes an error.
stateKey
or instanceKey
definedLeaving this here as a reminder to myself to look into it. Something about 0.5.0 or 0.5.1 broke the ability to import helpers. This is possibly caused by the addition of a peer dependency, we need to look into it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.