ember-required-properties
Features
This addon enables the following pattern:
export default Component.extend(RequiredProperties, {
requiredProperties: ['thing', 'another', 'on-select-thing']
});
{{some-component}}
ERROR: You must provide `thing`, `another`, and `on-select-thing` to {{some-component}}.
Like ember-prop-types
, this addon helps ensure required properties are passed to components. This addon is intended to be a much smaller building block. It only verifies required properties are present, not that they are of the correct type.
Installation
ember install ember-required-properties
Usage
Import the mixin anywhere you want to require properties:
import RequiredProperties from 'ember-required-properties/mixins/required-properties';
export Component.extend(RequiredProperties, {
requiredProperties: ['one', 'two']
});
Now if you fail to pass all of the required properties you will get an error.
NOTE: since we use Ember.assert
to throw errors, production will silently fail.
About Echobind
Ember Required Properties is maintained and funded by Echobind.
@echobind
We love open source! See our other projects or hire us to help bring your idea to life.
Legal
Echobind LLC (c) 2016
@echobind
Licensed under the MIT license