/ember-shared-memory

share memory between instances of the same class/component or across any kind of class

Primary LanguageJavaScriptMIT LicenseMIT

ember-shared-memory

npm version CI

Share objects and values between instances of things.

Share memory between:

  • components
  • components <-> services
  • vanilla classes or other things
  • any class

Why would you want to do this?

A common use case is when showing search results on a page, you may have multiple renderings of the same component on that page -- maybe a "Top Result" that is duplicated further down the page under categorized results.

using @shared allows you to not re-compute that data for the duplicatenly rendered components.

Compatibility

  • Ember.js v3.25+
  • TypeScript v4.2+

Installation

npm install ember-shared-memory
# or
yarn add ember-shared-memory
# or
ember install ember-shared-memory

Usage

import Component from '@glimmer/component';

export default class MyComponent extends Component {
  @shared
  get worksOnGetters() { /* ... */ }

  @shared 
  propertyA = 'any value';


  @shared(() => [/* custom keys */])
  propertyB = 'any value';
}

Testing

TODO

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

Thanks

This library wouldn't be possible without the work of:

So much appreciate for the work both you have put in to Resources <3