Skip to content

Tags: e-oz/ngx-collection

Tags

v4.3.2

Toggle v4.3.2's commit message
Add Angular v19 to the list of supported versions in dependencies.

v4.3.1

Toggle v4.3.1's commit message
Callbacks `onSuccess()` and `onError()` were called before `$items` w…

…as updated. `$items()` inside the callbacks had a non-updated value.

v4.3.0

Toggle v4.3.0's commit message
New fields:

* `$lastReadError`
* `$lastReadOneError`
* `$lastReadManyError`
* `$lastRefreshError`

In params structures, fields `readRequest` and `refreshRequest` are deprecated (will be removed in v5).
Use `read` and `refresh` instead.

v4.2.3

Toggle v4.2.3's commit message
New method: `fetchItem()`!

This method will check if the item exists in the collection and return it if it does.
If the item does not exist, the `request` argument will be used to fetch the item and add it to the collection.
If the option `fetchItemRequestFactory` is set, the `request` argument is optional.
If both are missing, the resulting Observable will throw an error.

v4.2.2

Toggle v4.2.2's commit message
`createEffect.forValue()` renamed to `getEffectFor()`.

v4.2.1

Toggle v4.2.1's commit message
Experimental method for `createEffect()`: `forValue()`, which takes a…

… value and returns an observable that will execute the effect when subscribed.

v4.2.0

Toggle v4.2.0's commit message
* New (experimental!) methods: `readFrom` and `readManyFrom`. Can be …

…called as part of constructor options.

* `EffectFnMethods` renamed to `EffectObservables`, and lost methods `next`, `error` and `complete` - the same functionality with a less ambiguous API can be achieved with `EffectListeners`. This API is considered stable now.

v4.1.3

Toggle v4.1.3's commit message
* Use `untracked()` every time when reactive context should not be af…

…fected;

* Use `take(1)` instead of `first()` to prevent `no elements in sequence` exception.

v4.1.2

Toggle v4.1.2's commit message
Improved API for `createEffect()` listeners, introduced in v4.1.1.

v4.1.1

Toggle v4.1.1's commit message
### 4.1.1

`createEffect()` now returns not just a function, but a function with methods! :)
API is experimental and might change,  so it's documented only here for now.

In your store:

```ts
import { createEffect } from './create-effect';

class Store extends Collection<Item> {
  readonly changeZipCode = createEffect<string>(_ => _.pipe(
    // code to change zipcode
  ));
}
```

In your component:

```ts
class Component {
  store = inject(Store);
  dialog = inject(Dialog);

  changeZipCode(zipCode: string) {
    this.store.changeZipCode.nextValue(() => this.dialog.close());
    this.store.changeZipCode(zipCode);
  }
}
```

In this example, the dialog window will be closed only *after* the service response, and only if it was successful.

Alongside nextValue, there are other methods:
```ts
export type EffectFnMethods = {
  nextValue: (fn: ((v: unknown) => void)) => void,
  nextError: (fn: ((v: unknown) => void)) => void,
  onNextValue(): Observable<unknown>,
  onNextError(): Observable<unknown>,
};
```

Internally, values and errors will not be saved in memory if you don't use these methods.