Skip to content

createRepeat

Created by Lucas Garcia

Import

import { createRepeat } from 'ngxtension/create-repeat';

Usage

Create an RxJS repeat operator with an emit method on it, to notify when the source should be repeated.

@Component({
...,
template: `
...
<button (click)="repeat.emit()">Repeat</button>
`
})
export class SomeComponent {
readonly repeat = createRepeat();
// Will log 'hello' directly, then each time the 'Repeat' button gets clicked
readonly #sayHello = rxEffect(of('hello').pipe(this.repeat()), console.log);
}

API

createRepeat overloads

Overload 1

argumentstypedescription
globalCountnumberOptional. Default is undefined.
The number of times (applied globally) the source Observable items are repeated (a count of 0 will yield an empty Observable)
destroyRefDestroyRefOptional. Default is undefined.
The DestroyRef to pass when createRepeat is used outside of an injection context.

Overload 2

argumentstypedescription
destroyRefDestroyRefOptional. Default is undefined.
The DestroyRef to pass when createRepeat is used outside of an injection context.

Returned repeat operator

argumentstypedescription
countnumberOptional. Default is undefined.
The number of times the source Observable items are repeated (a count of 0 will yield an empty Observable)

See also