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
WIP docs #156
Comments
I think the patterns are key. I know the slogan is domvm wont hold your hand but having patterns defined will help newcomers, especially with the |
yeah, this and probably third-party lib interop. most will want to know whether they'll be required to re-implement all their favorite deps:
drop a tip/link to the 💡 You can set up auto-redraw using the global plus perhaps a router setup example with subviews. (admin backend navigation example)
i'd say that presenting a bunch of different patterns is in line with that statement; there's no "one right way". |
I agree with the interop priority. In fact, I have a calendar widget in Mithril that I need to port to DOMVM. If I were asked to prioritize the above list, I think I would have: Primary:
Secondary:
|
Here is my personal ordering of the topics (omitting ones that I don't know how to use or when to use) General
|
no, its just dom events. hooks are always called hooks. however, i do see some possible confusion introduced between they'll be mentioned in different doc sections, so it wont necessarily be confusing at that point but i imagine reading your own code later won't be ideal: function View(vm) {
vm.config({
onevent: function(e) {
vm.redraw();
},
events: {
something: function() {}
}
})
} post-1.x i personally don't use emit in my apps. what i used it for previously has been replaced by i like to keep names short, so perhaps this also brings up the question whether it's worth adding a matching global EDIT: i started doing the impl for this and decided against the single-handler signature for |
ok, I missed the part where this is a list of remaining items for documentation (lifecycle hooks are already documented). thanks for the clarification |
alright, |
I use emit in my largest app for synthetic events derived from input events. I don't mind a few renames when the time comes to upgrade that, which will be sooner rather than later. I think it's a useful construct to have available. I like the use of "emit" for "emit handlers". |
Nevermind; I see it was added on 2017-07-06. And updating to 3.x-dev current, the vm onevent works fine. |
Also, all global actions must document the caveat of having to consider what might happen if a third-party component is used. And by that I mean a third-party DOMVM component, specifically, though global event handlers might be impacted by anything external. |
yeah, the docs should mention that global config should only ever be setup by your own app, not by any of your components or third-party dependencies. though |
Just spent a few hours upgrading a pre-DEVMODE app to 3.1. Everything felt pretty natural, but since emit events are seeing further changes, can we consider restoring the emitted value as the first argument. Since I am already calling |
restoring? i don't believe it ever worked this way. the current signature for emit handlers is you could make the argument [and maybe you are] that one could simply emit the originating vm as one of the arguments, if needed. i'll buy that as justification for this simplification. |
Well actually looking at the few places I do use emit, I am using imperative composition so the registered vm and the emitting vm are the same. I didn't even realize the events bubble up the parents until looking at the source. Bubbling actually provides little use for me since the associated imperative view may not even be a child in some cases. Regardless, In 2.x, the signature was just someView.on('move', data => { ... }) to: someView.config({
events: {
move(_, data) { ... }
}
}) |
so it appears i suffer from severe short-term memory loss [1]. it looks like this was done as part of the uniformity rampage [2]. a better argument for changing this is that emit's calling convention [and bubbling behavior] is similar to that of parameterized events: let's go ahead and do that then. how about we'd need to clarify in the docs that the vm/data is that of the emitting vm rather than the handler's vm, which could be a bit odd but would work the same way for any delegated dom event handlers in a parent vm ( [1] eb84d6d#diff-00459a3c4659fc80d15cdb0563ce43b4 |
🙏 please forgive me, semver gods! 🙏 |
[Deep Booming Voice] You are forgiven my son... now go and sin no more! |
i've added a bunch of docs, can you guys please look over them and see if they are clear enough and in logical order. 🙏 |
I thought auto-pixel was dropped in V3? |
no i just moved it up to |
Hmmm, I'd expect the following to be "Basic" event handlers, not "Fancy", since each is a simple function:
I'd expect to need to wrap each in an array to get a Fancy event handler:
|
In my experience, halting the propagation of an event nearly always causes subtle faults in any application of non-trivial size. Even if not applying default behavior, it is sometimes necessary to see an already handled event at higher levels in the DOM. Also, does this mean specifically |
i suppose this needs a more obvious explanation. fancy listeners are all proxied by an internal i could artificially not augment the arguments for non-array-wrapped delegated listeners, but the in addition, the vm-level and global
well, returning nothing would be generically falsey, so yes it's explicitly |
Just curious, do you really think that this: function StepperView(vm, stepper) {
var add = stepper.add.bind(stepper);
function set(e) {
stepper.set(e.target.value);
}
... is equally as clear as this: function StepperView(vm, stepper) {
function add(val) {
stepper.add(val);
}
function set(e) {
stepper.set(e.target.value);
}
... ? I only ask because this is an example, and I had to think about it for a bit to realize that the two functions were logically equivalent; it seems to me that the latter is considerably more obvious. Which may, of course, be my relative inexperience with Javascript vs. Java and C. (Also, my mind would have followed the code just a tad easier if the SteeperView function had followed the Stepper function, since the former is used by the latter.) |
Perhaps document whether the invocation of the listener is inline or deferred to the event queue or RAF queue? That could be subtly important in some instances. |
Document the various hooks' arguments in this section. |
no. good point.
makes sense.
yep, will do.
can you elaborate when this would be important and why "synchronous" cannot simply be assumed, considering that everything that's asynchronous is already explicitly called out? thanks for the review! |
Because, to me, things like "events" and "signals" are always asynchronous; while "listeners" are always synchronous. However, the emit system seems to be in a gray area where it's not clearly one or the other. It's described with nomenclature for both. |
that only answers half the question, tho. when would sync and async emit signals behave differently? why is it important? |
Oh, that's easy to illustrate. Consider, for arguments sake, an inline "redraw" function. Now consider a property get/set function that invokes an application listener when the property is to be changed, allowing the listener to alter the value or even veto on the change by returning the existing value. Now, the application is coded to use the change listener to emit a "model-change" event while the VM uses the "model-change" event to trigger redraw of the entire view. On the surface it all seems reasonable enough for a decoupled system. But at the point where the listener is invoked is immediately before actually setting the underlying value (since the listener can alter/veto the value). Since emitted events are also inline and redraw is also inline, the call sequence looks like:
and the view is recreated with the old value. If the emit system is viewed as a listener system inline is intuitive; but as an eventing system the result is counter-intuitive; the app developer expected:
I know, because I was that developer (using Mithril, I think). It was immensely confusing because it only actually failed when the property was set outside of an event (which in Mithril always triggered a subsequent redraw). These details do matter, IMHO. |
ok, that makes sense. however, i'm not convinced that the terminology you're using has the widely-accepted expectations you're implying. i agree that "signals" can be removed. but the emit system is a bubbling event system just like dom events, which has "event listeners" and is fully synchronous - it's not a pub-sub. however, sending events into a view externally via i do want to draw paralells between how dom events work and how the emit system works in the prose, because it doesnt introduce extra cognitive load or new terminology. |
Correct me if I am wrong, but dispatching an event simply drops an event object on the event queue, it does not actually bubble the event and invoke its listeners synchronously. Therefore, to match event dispatch, the Technically achieving that in Javascript might be a quite different matter. :-| |
to my knowledge, dispatching and bubbling of dom events behaves synchronously in userland, otherwise every [1] https://github.com/leeoniya/domvm/blob/3.x-dev/test/src/events.js |
I stand corrected, and this is even consistent with Java where References to "signal" should be removed; they are, I think, misleading. And I think it should be described in similar terms to I think it would also be useful for there to be a caveat on the global event listeners, like other "global" things, describing considerations for components developed in isolation of the app. All of this makes me wonder if providing
|
i updated the docs.
"global" means the same thing in every language, with the same footguns. most devs should already understand the implications of such things.
it's extra API surface which you can add yourself, even on the ViewModel prototype if you so please. i don't see any reason to offer asynchronous code over clearer synchronous code. |
That's much clearer. Small typo in "There is also a global emit listener which will fires for all emit events." |
most of the Optimization section has been written. |
Third-Party Integration is done: https://github.com/leeoniya/domvm#third-party-integration getting close! |
Maybe make the life-cycle hooks will/didInsert(newNode) => |
In looking at the hooks docs, though, there's an inconsistency between Of course, it's probably not worth changing now. |
Yeah, maybe a bit. However, i like that they're distinctively-named since they have different args and vms have corresponding |
added:
|
I suppose these must be part of the core? Might there be a reduction in size if these could be moved to a higher build? |
yes, these are the core. i just exposed them for easy extending. i may move |
Yeah, there's no point in shuffling things out of pico unless it improves the overall design and decoupling of the core. For all practical purposes, nano is the minimum build. |
After reading the docs, it's not at all clear to me what the utility for |
|
I think the title of "What's Missing?" wrongly implies that DOMVM is deficient. I think that section should be included in the intro, under a sub-title like "What DOMVM Is Not", or something similar that denotes scope-restriction rather than functional lack. PS: Although it's pedantic, "Into" should be "Introduction". |
Also, the documentation index should, I think, be immediately after the Introduction, with the Demo Playground included in that list. It provides an overview to all the information to the page. Indeed, an argument can be made for having it as the first section and including Introduction in the list of links. |
👍
👍
eh. domvm is meant for a technical audience. personally, i always want examples first and docs second, only if the examples already "felt right". the index is an entire extra screen of scrolling. |
I just did a scan of my code and I don't use |
@leeoniya : I suggest closing this. |
some of this stuff is briefly mentioned in https://github.com/leeoniya/domvm#templates and easily overlooked, other stuff requires reading the code of the demos, and the rest is just plain missing. i think the list below represents a fairly thorough todo list for the docs.
does anyone have a good feel for how best to prioritize the items in terms of greatest impact?
cc @lawrence-dol @iamjohnlong @sabine @tropperstyle @e1ectronic @xz64
General:
Object.assign()
The text was updated successfully, but these errors were encountered: