New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add alternative way of adding actions #59
Comments
@christianmalek What about define using standard ES6 class + typescript decorators? It could be done in very elegant way. Something similar to https://github.com/championswimmer/vuex-module-decorators . It would added autocimplete in IDE + allow do automatic refactoring. |
@Koc I will look into this. This looks pretty nifty. Thanks for sharing! |
I wrote a detailed comment on this proposed change in a less relevant issue (whoops!): |
@slurmulon Thanks for your input! I agree with all of your arguments. If someone really wants to have a "simpler" approach he/she could write an helper method to please his needs. =) // without helper
.get({
property: 'post',
action: 'getPost',
path: ({id}) => `posts/${id}`
})
// with helper (just an example)
.get(helper("post", "getPost", ({id}) => `posts/${id}`)) |
this structure would allow to easily generate actions from some data source .actions({
getPost: {
method: 'GET', // if undefined try to get it from action's name
path: ({ id }) => '/post/${id}',
property: 'post'
},
getPosts: {
path: '/posts',
property: 'posts'
}
}) |
I'm planning to add a very simple way of adding actions as string.
At the moment actions can be added like this:
The alternative version I'm looking forward to looks like this:
Or maybe like this:
One nice side effect would be that you didn't have to write the path function if it's that easy. The params will be detected (e.g.
:id
) and automatically added.Please consider: This is just a draft. I'll maybe change the syntax or did overlook some problems.
The text was updated successfully, but these errors were encountered: