Skip to content
This repository was archived by the owner on Jan 9, 2020. It is now read-only.

Commit a160969

Browse files
committed
fix: declareStep() now working
1 parent 67b9b5c commit a160969

4 files changed

Lines changed: 14 additions & 29 deletions

File tree

rollup.config.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,5 @@ export default {
66
file: pkg.main,
77
format: 'cjs'
88
},
9-
external: [
10-
'kronos-endpoint',
11-
'kronos-service',
12-
'loglevel-mixin',
13-
'model-attributes'
14-
]
9+
external: ['kronos-endpoint', 'kronos-service', 'loglevel-mixin']
1510
};

src/step-provider-mixin.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
1-
import { defineRegistryProperties } from 'registry-mixin';
2-
31
/**
42
* Provide steps.
53
*/
64
export function StepProviderMixin(superclass) {
7-
return class extends superclass {
8-
/**
9-
* if config is an array entry 0 then entry 0 will be passed to super and all other entries
10-
* are handed over as initial config to the config services
11-
*/
5+
return class StepProviderMixin extends superclass {
126
constructor(...args) {
137
super(...args);
148

15-
defineRegistryProperties(this, 'stepFactory', {
16-
pluralName: 'stepFactories',
17-
withCreateInstance: true,
18-
withEvents: true,
19-
factoryType: 'new'
20-
});
9+
Object.defineProperty(this, 'registeredSteps', { value: new Map() });
10+
}
11+
12+
registerStep(step) {
13+
this.registeredSteps.set(step.name, step);
2114
}
2215

23-
declareStep(config, owner) {
24-
return this.createStepFactoryInstanceFromConfig(config, owner);
16+
declareStep(config, ...args) {
17+
const factory = this.registeredSteps.get(config.type);
18+
return new factory(config, ...args);
2519
}
2620
};
2721
}

tests/rollup.config.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ export default {
77
format: 'cjs',
88
sourcemap: true
99
},
10-
external: [
11-
'ava',
12-
'kronos-endpoint',
13-
'kronos-service',
14-
'loglevel-mixin',
15-
'model-attributes'
16-
],
10+
external: ['ava', 'kronos-endpoint', 'kronos-service', 'loglevel-mixin'],
1711
plugins: [multiEntry()]
1812
};

tests/step-provider-mixin-test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ class AStep extends Step {
88
}
99
}
1010

11+
class Provider extends StepProviderMixin(class {}) {}
12+
1113
test('provider', async t => {
12-
const provider = new StepProviderMixin(class {});
14+
const provider = new Provider();
1315

1416
provider.registerStep(AStep);
1517

0 commit comments

Comments
 (0)