Skip to content

Commit

Permalink
Merge pull request #954 from NullVoxPopuli/changeset-release/main
Browse files Browse the repository at this point in the history
Release Preview
  • Loading branch information
NullVoxPopuli authored Jul 20, 2023
2 parents 4b1f708 + 61b5b86 commit 3002ec8
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 62 deletions.
61 changes: 0 additions & 61 deletions .changeset/polite-tips-bow.md

This file was deleted.

62 changes: 62 additions & 0 deletions ember-resources/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,67 @@
# ember-resources

## 6.3.0

### Minor Changes

- [#952](https://github.com/NullVoxPopuli/ember-resources/pull/952) [`1551b33`](https://github.com/NullVoxPopuli/ember-resources/commit/1551b33ae62f650c8f9bbdefe2aa1cffad44188f) Thanks [@NullVoxPopuli](https://github.com/NullVoxPopuli)! - Introduce resources as modifiers.
This brings alignment with Starbeam's plans for modifiers as a universal primitive.

In ember-resources, using modifiers as resources looks like this:

```js
import { resource } from 'ember-resources';
import { modifier } from 'ember-resources/modifier';

const wiggle = modifier((element, arg1, arg2, namedArgs) => {
return resource(({ on }) => {
let animation = element.animate([
{ transform: `translateX(${arg1}px)` },
{ transform: `translateX(-${arg2}px)` },
], {
duration: 100,
iterations: Infinity,
});

on.cleanup(() => animation.cancel());
});
});

<template>
<div {{wiggle 2 5 named="hello"}}>hello</div>
</template>
```

The signature for the modifier here is _different_ from `ember-modifier`, where positional args and named args are grouped together into an array and object respectively.

This signature for ember-resource's `modifier` follows the [plain function invocation](https://blog.emberjs.com/plain-old-functions-as-helpers/) signature.

<details><summary>in Starbeam</summary>

```js
import { resource } from '@starbeam/universal';

function wiggle(element, arg1, arg2, namedArgs) {
return resource(({ on }) => {
let animation = element.animate([
{ transform: `translateX(${arg1}px)` },
{ transform: `translateX(-${arg2}px)` },
], {
duration: 100,
iterations: Infinity,
});

on.cleanup(() => animation.cancel());
});
}

<template>
<div {{wiggle 2 5 named="hello"}}>hello</div>
</template>
```

</details>

## 6.2.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion ember-resources/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-resources",
"version": "6.2.2",
"version": "6.3.0",
"keywords": [
"ember-addon"
],
Expand Down

0 comments on commit 3002ec8

Please sign in to comment.