Skip to content

[rewrite] Piecemeal usage #1132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tivac opened this issue Jul 1, 2016 · 4 comments
Closed

[rewrite] Piecemeal usage #1132

tivac opened this issue Jul 1, 2016 · 4 comments
Milestone

Comments

@tivac
Copy link
Contributor

tivac commented Jul 1, 2016

There have been multiple calls for mithril to be made more modular, and I think there's some value in that. With the way the rewrite branch has been structured that's now possible, so here's an approach at defining how you might actually use just certain pieces of mithril.

This continues from the previous discussion in #1044 (comment)

// Everything
var m = require("mithril");

// Just the hyperscript function
var m = require("mithril/m");

// Just the router
var router = require("mithril/router");

This complicates manual redrawing some since m.redraw() won't just be stuck on m for users doing the piecemeal requires, but that can probably be another module that can be grabbed if necessary.

var mount = require("mithril/mount");
var redraw = require("mithril/redraw");

mount(document.body, Component);

setTimeout(redraw, 1000);
@tivac tivac added this to the Rewrite milestone Jul 1, 2016
@tivac tivac mentioned this issue Jul 1, 2016
22 tasks
@hugufc
Copy link
Contributor

hugufc commented Jul 14, 2016

I think that router requires a redraw as a peer dependecy, whatever it is mithril or third party. I was thought on plugRedraw() but it's very verbose.

@dead-claudia
Copy link
Member

@hugufc I'm not sure how useful the router is without Mithril itself. The routing is inherently coupled mainly because of the API itself, and there's hardly a use case. It's simple enough you could adapt it to something else, though (and it could be done within a few hours max unless you all have very testing requirements comparable to NASA's).

@lhorie
Copy link
Member

lhorie commented Aug 17, 2016

update: I merged @sebastiansandqvist's PR as a starting point for this and made a few changes

Currently, these piecemeal modules exist:

  • mithril/route
  • mithril/mount
  • mithril/stream
  • mithril/render
  • mithril/redraw

Caveat: the last two (render and redraw) expose their parent objects and not the methods themselves, so consider them work in progress. The reason I haven't exposed those two properly has to do w/ some issues in bundler that I need to fix...

I haven't aliased mithril/render/hyperscript and mithril/render/trust but those should be easy to do if anyone wants to send a PR

@dead-claudia
Copy link
Member

With the current state of things, I'd consider this done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants