Skip to content
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

Support default value when not called yet #11

Open
mokkabonna opened this issue Jun 30, 2020 · 0 comments
Open

Support default value when not called yet #11

mokkabonna opened this issue Jun 30, 2020 · 0 comments

Comments

@mokkabonna
Copy link
Owner

mokkabonna commented Jun 30, 2020

The default value is now null. It could be handy if especially for methods that return an array to have the init value be an empty array.

Just don't want to create an config object just for that little functionality, like:

fetchBooks: {
  defaultValue: [],
  handler() {
    return api.fetchBooks()
  }
}

I think it would be better to do something convention based, like the computed name convention. Maybe:

fetchBooksList() {
  return api.fetchBooks()
}

and a default function that interprets that like:

function getDefaultValue(vm, methodName) {
  var useArray = /List$/.test(methodName)
  return useArray ? [] : null
}

And make that function replaceable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant