Skip to content

Official component/utility library #2284

Closed
@dead-claudia

Description

@dead-claudia
Updates
  • Add query string utils to the list of things to pull out.
  • Add request utils to the list.
  • Add hydration to the list.
  • Strike a sentence that's no longer true.

Now that we're starting to see several common themes, I don't think it'd be a terrible idea to start having an official userland component/utility library for the common requests and things otherwise broadly useful. For example:

  • Async: See Add a built-in component for async view loading #2282. It simplifies async view loading to something that's a lot easier to use.
  • Route: The router itself might qualify for inclusion here if we go for Make the router use components, but only accept view functions #2281.
    • m.buildQueryString and m.parseQueryString should be transferred with this - they're not broadly useful outside routing.
    • Link: For the common case of m("a", {oncreate: m.route.link(opts = {})}), a lot of people (me included) would like to see an easier way of specifying links than this verbosity. This one is probably the only one that really merits core inclusion, though.
  • SelfSufficient: We've decided that it belongs in userland, but there's been so many requests for this both here and on Gitter for subtree management that I feel it needs a more centralized home.
  • stream: Mithril's streams library really belongs here, not necessarily at the top level.
  • Request: Mithril's request library, m.request/m.jsonp, could fit here, if we want to keep most of the batteries out of core.
    • A lot of people are good enough with just using fetch, so I'm not sure this is as broadly useful in core as it used to be. If you're stuck on IE, you of course would still appreciate this.
  • hydrate: We've decided it's probably not ideal to include in core, but it'd definitely be worth having at least supported in some official capacity.
    • We also need to ensure that 1. the DOM is what we expected (and patch it if it isn't), and 2. our internal state is initialized correctly.
    • We'd have to replace text nodes in any case where we have either multiple text nodes or a child component.
    • This would likely have to directly manipulate some internal stuff if we hope for it to be reasonably fast.
    • Or in other words, it's non-trivial and it probably doesn't belong fully in userland.

Each of these would be distinct utilities out of core, not shipped with the main bundle. This would almost function like Mithril's "standard library", basically anything that doesn't belong in Mithril itself, but is still useful nevertheless.

My thought is adopting mithril/util/${module} for each of these, where mithril/util re-exports everything. Of course we currently do have such a subfolder, but we could rename that to core-util, things we ship with the main bundle, to make room for this new namespace. Edit: removed as of #2317.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: Meta/FeedbackFor high-level discussion around the project and/or community itself

    Type

    No type

    Projects

    Status

    In discussion

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions