JackCA / ember-required-properties

Enforce required properties on components or other objects via a simple mixin.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ember-required-properties

CircleCI npm version Code Climate Dependency Status Ember Observer Score

Features

This addon enables the following pattern:

// some-component
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

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

About

Enforce required properties on components or other objects via a simple mixin.

License:MIT License


Languages

Language:JavaScript 88.2%Language:HTML 11.8%