capi
capi copied to clipboard
initializing runes from constants
Currently, we do the following:
const rune = Rune.constant(theValue).into(TheRuneSubclassCtor)
Let's consider a larger example.
const denoFsHost = Rune
.constant({
readFile(filePath: string) {
return Deno.readFile(filePath)
},
// more ...
})
.into(FsHostRune)
If we rework the design as follows...
- the parameter types can be inferred
- we need not import
Rune - confusion about the meaning of
Rune.constantis avoided entirely (#569) - the code is more legible
const denoFsHost = FsHostRune.of({
readFile(filePath) {
return Deno.readFile(filePath)
},
// more ...
})
This is in line with my suggestion from #569:
I think
Rune.resolveshould be renamed toRune.from. Then, it can be redesigned to work with subclasses, such thatFooRune.from(runic, ...ctorArgs)is a shorthand forRune.resolve(runic).into(FooRune, ...ctorArgs)(though I would need to confirm that the typing is fine).
Blocked on #517
EDIT
Indeed @tjjfvi, I commented on the wrong issue. Ignore.
@harrysolovay I think you commented on the wrong issue?