Skip to content

Instantly share code, notes, and snippets.

@jorroll
Created November 4, 2019 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorroll/ec43f8c702354b925a0e8a04b9be7364 to your computer and use it in GitHub Desktop.
Save jorroll/ec43f8c702354b925a0e8a04b9be7364 to your computer and use it in GitHub Desktop.
class FormControl<Value = any, Data = any>
implements AbstractControl<Value, Data> {
id: ControlId;
constructor() {
this.source
.pipe(
filter(
// make sure we don't process an event we already processed
event => !event.processed.includes(this.id),
),
)
.subscribe(event => {
event.processed.push(this.id);
if (!event.meta) event.meta = {};
if (!event.id) event.id = AbstractControl.eventId();
const newEvent = this.processEvent(event as ControlEvent);
if (newEvent) {
this._events.next(newEvent);
}
});
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment