Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/scully-lib-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,22 @@ getState<T>(name: string): Observable<T>
setState<T>(name: string, val: T): void;
```

#### useScullyTransferState

`useScullyTransferState` - Wraps an observable into scully's transfer state.

If data for the provided `name` is available in the state, it gets returned. Otherwise,
the `originalState` observable will be returned.

On subsequent calls, the data in the state will always be returned. The `originalState` will
be returned only once.

This is a convenience method which does not require you to use `getState`/`setState` manually.

```typescript
useScullyTransferState<T>(name: string, originalState: Observable<T>): Observable<T>;
```

## utility-methods

These methods provide useful information about Scully processes.
Expand Down
13 changes: 13 additions & 0 deletions libs/ng-lib/src/lib/transfer-state/transfer-state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,19 @@ export class TransferStateService {
this.nextUrl.subscribe();
}

/**
* Wraps an observable into scully's transfer state. If data for the provided `name` is
* available in the state, it gets returned. Otherwise, the `originalState` observable will
* be returned.
*
* On subsequent calls, the data in the state will always be returned. The `originalState` will
* be returned only once.
*
* This is a convenience method which does not require you to use `getState`/`setState` manually.
*
* @param name state key
* @param originalState an observable which yields the desired data
*/
useScullyTransferState<T>(
name: string,
originalState: Observable<T>
Expand Down