Closed abritinthebay closed 6 years ago
Hello @abritinthebay. Since currently react-blessed
only requires blessed
to do some argument validation here, I guess it wouldn't be very hard to drop it from the code and let the user install whichever version.
@Yomguithereal the blessed
is also used here and here. If I understand correctly, the idea was that render
acts the same way as ReactDOM.render
and accepts the same arguments. How do you think passing the blessed
instance should be handled then?
I couldn't think of any way that wouldn't break backwards-compatibility, something like:
const render = createBlessedRenderer(blessed)
// and now render(<Foo/>, bar)
This could be added next to the old render
to allow both but if I understand node packaging correctly, it'd still require bundling blessed
itself with react-blessed
which is a non-ideal situation (correct me if I'm wrong, I've always precompiled my libraries with webpack/rollup)
Looked at the compiled code and I see require
calls are untouched which means we could add createBlessedRenderer
as extra thing and make the old render
still work. Let me know if you're ok with this approach and I'll come up with a PR.
Sounds fine to me! Can always look st conditional requires to reduce package size at a later date!
Can I get a maintainer blessing so I know it makes sense to spend time on this PR? :) cc @Yomguithereal
Go ahead @d4rky-pl. We agree that a factory here would only enable people to use forked versions of blessed, right? Creating the renderer factory is easy however, creating factory for the reconciler etc. might prove a bit tedious to implement but I don't remember the code base enough to say.
@Yomguithereal since reconciler is never exported outside (because it's an implementation detail), I just wanted to move it's initialization to the factory method and take advantage of javascript scoping.
I'll try to spend some time this weekend to deliver a PR (or at least POC) but to be honest I expect this to be mostly a bit of code shuffling and not a major rewrite.
Given blessed is... somewhat unmaintained, it would be nice to be able to pass in a different function to be used (ie - only require blessed if none is passed). That way we could use forked versions with updated code.
Thoughts?