{"action":"created","issue":{"url":"https://api.github.com/repos/lhorie/mithril.js/issues/1044","repository_url":"https://api.github.com/repos/lhorie/mithril.js","labels_url":"https://api.github.com/repos/lhorie/mithril.js/issues/1044/labels{/name}","comments_url":"https://api.github.com/repos/lhorie/mithril.js/issues/1044/comments","events_url":"https://api.github.com/repos/lhorie/mithril.js/issues/1044/events","html_url":"https://github.com/lhorie/mithril.js/issues/1044","id":154796544,"number":1044,"title":"[rewrite] Rest of the API","user":{"login":"isiahmeadows","id":4483844,"avatar_url":"https://avatars.githubusercontent.com/u/4483844?v=3","gravatar_id":"","url":"https://api.github.com/users/isiahmeadows","html_url":"https://github.com/isiahmeadows","followers_url":"https://api.github.com/users/isiahmeadows/followers","following_url":"https://api.github.com/users/isiahmeadows/following{/other_user}","gists_url":"https://api.github.com/users/isiahmeadows/gists{/gist_id}","starred_url":"https://api.github.com/users/isiahmeadows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isiahmeadows/subscriptions","organizations_url":"https://api.github.com/users/isiahmeadows/orgs","repos_url":"https://api.github.com/users/isiahmeadows/repos","events_url":"https://api.github.com/users/isiahmeadows/events{/privacy}","received_events_url":"https://api.github.com/users/isiahmeadows/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/lhorie/mithril.js/labels/rewrite","name":"rewrite","color":"0e8a16"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":48,"created_at":"2016-05-13T20:44:20Z","updated_at":"2016-05-31T22:04:20Z","closed_at":null,"body":"Since we're starting to get to that point, I think it's a good idea to start thinking of the rest of the high-level API. Here's some of my ideas:\r\n\r\n- `Mithril.m(type, attrs?, ...children)`\r\n\r\n    The familiar `m()` hyperscript API.\r\n\r\n- `var trust = Mithril.trust`\r\n\r\n- `var mountpoint = Mithril.mount(window = global.window)`\r\n\r\n    Ideally, this should return an object you can use to do `m.redraw()`-like things and have multiple independent roots. The argument is for easy mocking, and effectively nullifies `m.deps`.\r\n\r\n- `mountpoint.window`\r\n\r\n    This is the window value argument passed to `Mithril.mount()`, defaulting to the global window. You can also use a JSDOM window if you want to use it in Node.\r\n\r\n- `var promise = mountpoint.redraw()`\r\n\r\n    This should do the equivalent of 0.2's async `m.redraw()`, but return a Promise.\r\n\r\n- `mountpoint.redrawSync()`\r\n\r\n    This should do the equivalent of 0.2's sync `m.redraw(true)`, and return nothing.\r\n\r\n- `mountpoint.redrawStrategy = \"all\" | \"diff\" | \"none\"`\r\n\r\n    This fufulls the same purpose as `m.redraw.strategy()`. It might not be necessary with the lifecycle methods, though.\r\n\r\n- `var promise = mountpoint.compute(callback: () => Promise | void)`\r\n\r\n    This should take the place of `m.startComputation` and `m.endComputation`. It is roughly equivalent to the following code:\r\n\r\n    ```js\r\n    m.startComputation()\r\n    return Promise.resolve(callback()).then(() => {\r\n        m.endComputation()\r\n    })\r\n    ````\r\n\r\n- `Mithril.prop(init?, observer?)`\r\n\r\n  `m.prop` is popular enough that it should probably stay in core. I do believe it should lose the Promise absorbing semantics, though, and it should be optionally observable.\r\n\r\n- `Mithril.withAttr(value, callback, thisArg)`\r\n\r\n  `m.withAttr` also seems popular enough that it could remain in core, with few modifications (mostly removing compat bloat).\r\n\r\n---\r\n\r\nThe rest are generally not necessary/needed in the core distribution.\r\n\r\n- `m.route` can be implemented on top of `m.mount` in a third-party module.\r\n- `m.component` can (and should) die.\r\n- `m.request` should be go away in favor of the native Fetch API, and there is an XHR-based polyfill if you need one. IMHO, redraw after request should be explicit, anyways.\r\n- `m.deferred` and `m.sync` should go away in favor of native Promises. If necessary, there's a ton of libraries and polyfills for that.\r\n\r\n/cc @tivac @lhorie "},"comment":{"url":"https://api.github.com/repos/lhorie/mithril.js/issues/comments/222835298","html_url":"https://github.com/lhorie/mithril.js/issues/1044#issuecomment-222835298","issue_url":"https://api.github.com/repos/lhorie/mithril.js/issues/1044","id":222835298,"user":{"login":"darsain","id":538801,"avatar_url":"https://avatars.githubusercontent.com/u/538801?v=3","gravatar_id":"","url":"https://api.github.com/users/darsain","html_url":"https://github.com/darsain","followers_url":"https://api.github.com/users/darsain/followers","following_url":"https://api.github.com/users/darsain/following{/other_user}","gists_url":"https://api.github.com/users/darsain/gists{/gist_id}","starred_url":"https://api.github.com/users/darsain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darsain/subscriptions","organizations_url":"https://api.github.com/users/darsain/orgs","repos_url":"https://api.github.com/users/darsain/repos","events_url":"https://api.github.com/users/darsain/events{/privacy}","received_events_url":"https://api.github.com/users/darsain/received_events","type":"User","site_admin":false},"created_at":"2016-05-31T22:04:20Z","updated_at":"2016-05-31T22:04:20Z","body":"@tivac you don't have to litter the repo root with anything. Just set up a build for npm. What's published to npm doesn't have to match the repo."}}
{"actor":{"display_login":"darsain"}}