Skip to content

A convenience decorator for Glimmer component argument default values

License

Notifications You must be signed in to change notification settings

abel-n/ember-argument-decorator

Repository files navigation

ember-argument-decorator

This decorator is a wrapper for providing argument defaults for Glimmer components in a simple manner. It supports primitives, objects and functions. It also seems to support getters but that is untested yet.

Compatibility

  • Ember.js v3.12 or above
  • Ember CLI v2.13 or above
  • Node.js v10 or above

Installation

ember install ember-argument-decorator

Usage

Provide default value in component.

import Component from '@glimmer/component';
import argument from 'ember-argument-decorator';

export default class XComponent extends Component {
  @argument searchEnabled = true
}

Use this.argumentName instead of @argumentName to refer to it in template.

{{#if this.searchEnabled}}
  {{!-- do something --}}
{{/if}}

The decorator updates the reference when arguments change.

<XComponent @searchEnabled={{optionalValue}} />

License

This project is licensed under the MIT License.