Skip to content
This repository was archived by the owner on Dec 18, 2019. It is now read-only.
This repository was archived by the owner on Dec 18, 2019. It is now read-only.

Composability of Cycle add-ons as wrapper functions #38

@kylecordes

Description

@kylecordes

This is not quite a bug report, more like a token of something to figure out when things are more mature.

I'm wondering about the composability of Cycle add-ons which arrive as a function which wraps the application main function. Once an application uses several of those, it needs to choose what order to wrap them. Wrapping does not seem to compose as well as adding drivers.

The specific case I hit was with onionify and cyclejs-modal:

https://github.com/cyclejs-community/cyclejs-modal

both of which arrive as a function to wrap around the application main function.

I ended up with this wrapping order:

const main = modalify(onionify(App));

... which yields both libraries working, with the caveat that onion state is not available within a component instantiated by modalify. This requires a workaround for state, carrying state needed for the modal by some means other than onion. (I briefly dabbled with a global variable, the allure of the dark side is sometimes strong...)

If I wrap them the other way, onion state is available inside the component instantiated by modalify - but modalify fails to work, for reasons I did not debug.

I would guess the fundamental challenge is: I'm using two libraries both of which expect to be the "outermost" wrapper function. Staring at the source code of both things, it's not clear to me what could be done to either to make their functionality mutually available to each other.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions