orbitjs / ember-orbit

Ember.js data layer built with Orbit.js
MIT License
320 stars 42 forks source link

Improve conditional creation of sources and strategies #401

Closed dgeb closed 2 years ago

dgeb commented 2 years ago

This builds upon earlier work in #399 which allowed source and strategy factories to conditionally return null or undefined to signal that they should be ignored by the coordinator factory. The issue with this approach is that the returned value still ends up in the application's container, and non-objects are not handled properly when the container is destroyed. This could cause issues in test teardown for instance.

Instead of returning a custom value from create, it is now recommended that the default export of the source or strategy module be conditionally changed to a non-factory (e.g. null or undefined) to signal that it should be ignored. This avoids the call to lookup and thus prevents nullish values from entering the container. Documentation and an example have been added to the README.