Skip to content

Conversation

nhunzaker
Copy link
Contributor

@nhunzaker nhunzaker commented Aug 15, 2016

Tapping into super within the constructor when extending Microcosm feels too low level. What do you think about adding a setup step? Personally, I think it indicates the intent much clearer.

Replaces:

class SolarSystem extends Microcosm {
  constructor(options) {
    super(options)
    this.addStore('planets', Planets)
  }
}

With:

class SolarSystem extends Microcosm {
  setup() {
    this.addStore('planets', Planets)
  }
}

This also eliminates a friction point: remembering to pass options into super().

@mackermedia
Copy link
Contributor

I like it. Explicit++ 👍

src/microcosm.js Outdated
// Standard store reduction behaviors
this.addStore(MetaStore)

// Microcosm is now ready. Call the initialize method
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call the initialize setup method.

Or rename setup to initialize?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Duh. I called this initialize before, but then changed it to setup because JS class libraries have a history of using init and initialize sort of like a constructor.

@greypants
Copy link
Contributor

👍 I like the change.

@nhunzaker nhunzaker merged commit f319c60 into master Aug 15, 2016
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 4570fd7 on nh-setup-step into e73b4a6 on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling f319c60 on nh-setup-step into e73b4a6 on master.

@nhunzaker nhunzaker deleted the nh-setup-step branch September 6, 2016 15:07
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

Successfully merging this pull request may close these issues.

4 participants