Skip to content

Commit

Permalink
Merge pull request #127 from grid-js/fix-125
Browse files Browse the repository at this point in the history
fix(pipeline): unregister should check the steps datatype (#125)
  • Loading branch information
afshinm authored Jul 4, 2020
2 parents 3d0b844 + f327d13 commit efbb15f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/pipeline/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,14 @@ class Pipeline<T, P = {}> extends EventEmitter<PipelineEvents<T>> {
if (!processor) return;

const subSteps = this._steps.get(processor.type);
this._steps.set(
processor.type,
subSteps.filter((proc) => proc != processor),
);
this.emit('updated', processor);

if (subSteps && subSteps.length) {
this._steps.set(
processor.type,
subSteps.filter((proc) => proc != processor),
);
this.emit('updated', processor);
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/pipeline/pipeline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ describe('Pipeline', () => {
expect(pipeline.steps).toHaveLength(1);
pipeline.unregister(null);
expect(pipeline.steps).toHaveLength(1);
pipeline.unregister(new NoopProcessor());
expect(pipeline.steps).toHaveLength(1);
pipeline.unregister(proc);
expect(pipeline.steps).toHaveLength(0);
});
Expand Down

0 comments on commit efbb15f

Please sign in to comment.