Open jasonkuhrt opened 3 years ago
const group = [a(), b(), c()]
const ctx = konn()
.useBeforeAll(group)
.done()
A problem with this is when downstream depends on upstream, then those types are lost in the group definition.
To fix we need a function helper.
const abc = join(a(), b(), c())
const ctx = konn()
.useBeforeAll(abc)
.done()
What if consumer wants to reuse repetitive parts of konn
chain?
const ctx = konn()
.useBeforeAll(a())
.useBeforeAll(b())
.useBeforeEach(c())
.done()
Ideas
const abc = konn()
.useBeforeAll(a())
.useBeforeAll(b())
.useBeforeEach(c())
// maybe another file, maybe multiple
const ctx = konn().use(abc).done()
.use
would take a callback to get the callback to be contravariant to the host ctx type:
const ctx = konn().use(thing).use({ _use: (ctx) => /* ... */ }).done()
This would require the konn
chain to have a _use
helper that would provide the needed static type state.
Alternative using a new API group
:
const abc = group()
.useBeforeAll(a())
.useBeforeAll(b())
.useBeforeEach(c())
.done()
// maybe another file, maybe multiple
const ctx = konn().use(abc).done()
Maybe different function name, providersGroup
instead of join
:
const abc = providersGroup(a(), b(), c())
const ctx = konn()
.useBeforeAll(abc)
.done()
Perceived Problem
What if consumer/producer wants to be able to have a,b,c providers packages up into one group of providers?
Ideas / Proposed Solution(s)