This release improves upon the previous release which allowed source and strategy factories to conditionally return null
or undefined
to signal that they should be ignored by the coordinator factory. This approach was flawed in that the returned value still ends up in the application's container, and non-objects are not handled properly by ember 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.
For example, the following strategy will be conditionally included for all non-production builds:
// app/data-strategies/event-logging.js
import { EventLoggingStrategy } from '@orbit/coordinator';
import config from 'example/config/environment';
const factory = {
create() {
return new EventLoggingStrategy();
}
};
// Conditionally include this strategy
export default config.environment !== 'production' ? factory : null;
Changelog
🚀 Enhancement
Committers: 1
- Dan Gebhardt (@dgeb)