Skip to content

Support default value when not called yet #11

@mokkabonna

Description

@mokkabonna

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions