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

Constructor changes #157

Closed
gr0uch opened this issue Jan 11, 2016 · 1 comment
Closed

Constructor changes #157

gr0uch opened this issue Jan 11, 2016 · 1 comment

Comments

@gr0uch
Copy link
Member

gr0uch commented Jan 11, 2016

I think that having separate methods to define record types and transform functions are unnecessary and that they should be defined up front in the constructor. This makes setup more declarative, removes possible user error of redefining types and transforms, and also allows the adapter connect method to be automatically called upon instantiation.

The new constructor could look like this:

fortune({
  adapter: { ... },
  serializers: [ ... ],
  types: {
    user: { ... } // record type definition
  },
  transforms: {
    user: { input, output }
  },
  settings: { ... }
})
.then(instance => { ... })

This makes connect to be called automatically, removes defineType, transform, transformInput, transformOutput, and would require a new major version. I would also like to remove the deprecated create method as well.

I'd also like to change the return value of the default export, it should return a Promise which resolves to the instance when connection is done.

Overall these changes would reduce unnecessary complexity in instantiating Fortune.js.

@gr0uch
Copy link
Member Author

gr0uch commented Jan 25, 2016

Refer to #166.

@gr0uch gr0uch closed this as completed Jan 25, 2016
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