https://github.com/nullvoxpopuli/ember-shared-memory
share memory between instances of the same class/component or across any kind of class
https://github.com/nullvoxpopuli/ember-shared-memory
hacktoberfest
Last synced: 10 months ago
JSON representation
share memory between instances of the same class/component or across any kind of class
- Host: GitHub
- URL: https://github.com/nullvoxpopuli/ember-shared-memory
- Owner: NullVoxPopuli
- License: mit
- Created: 2021-08-29T16:23:18.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-10-01T03:13:10.000Z (10 months ago)
- Last Synced: 2025-10-01T05:28:15.696Z (10 months ago)
- Topics: hacktoberfest
- Language: JavaScript
- Homepage:
- Size: 6.03 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ember-shared-memory
[](https://badge.fury.io/js/ember-shared-memory)
[](https://github.com/NullVoxPopuli/ember-shared-memory/actions/workflows/ci.yml)
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
```bash
npm install ember-shared-memory
# or
yarn add ember-shared-memory
# or
ember install ember-shared-memory
```
## Usage
```js
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](CONTRIBUTING.md) guide for details.
## License
This project is licensed under the [MIT License](LICENSE.md).
## Thanks
This library wouldn't be possible without the work of:
- [@pzuraq](https://github.com/pzuraq)
- [@josemarluedke](https://github.com/josemarluedke)
So much appreciate for the work both you have put in to Resources <3