-
-
Notifications
You must be signed in to change notification settings - Fork 421
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
Read window events through some driver #568
Comments
I'm inclined to just build this in the same fashion as BodyDOMSource and DocumentDOMSource, but I want to listen to other suggestions and criticisms to this proposal, in case we are missing something. E.g. do we want to allow |
You mean that |
It won't, just like |
👍 from me. I actually thought that was done already 😄 |
I'm fine with this as well 😄 can't see any glaring issues, will still be fine for testing. Just want to make sure it works with |
Thanks guys. 👍 |
What's the recommended way to track window dimensions before this issue resolves? |
My recommendation is to make a driver: import fromEvent from 'xstream/extra/fromEvent';
function windowSize () {
return {
width: window.innerWidth,
height: window.innerHeight
}
}
function resizeDriver () {
return fromEvent(window, 'resize')
.map(windowSize)
.startWith(windowSize())
.remember();
} |
I think |
Yeah window is generally considered part of the Browser Object Model, BOM, not the DOM.there is no BOM standard but all browsers support window (and history). Window is also the global context for javascript running in the Browser. I just create my own driver but we should really have an 'official' off the shelf story. My preference is another driver or the special selectors mentioned above. |
Hmm, I think I agree with @whitecolor. It's good if we define the boundaries of each library, so we don't end up with monoliths that do many things. Some time ago we moved out the HTML driver from cycle/dom, which was a good move, and was also @whitecolor's idea. When it comes to cycle/dom, I think a good purpose/scope for it is "it read/writes DOM Nodes", where "reads" concerns both DOM Nodes and events coming from DOM Nodes, and "writes" happens by managing VNodes.
As in many cases, it's best to first build it as non-official, then (maybe) officialize it. That has been the approach so far with cycle/history, cycle/time, (not yet, perhaps soon) cycle-onionify, etc. |
I've problem with that approach as the route to having one :) As long as devs can easily find the 'unoffical' one. I guess, without it seeming to be official :) |
Has there been any progress on a window driver? My use-case is keeping track of the window focus state. I'm currently going around the driver and listening directly on const isFocused$ = O.merge(O.fromEvent(window, 'focus').mapTo(true)
, O.fromEvent(window, 'blur' ).mapTo(false))) FWIW, I personally think that special-casing |
@shesek no, I havent gotten to that yet. But you can just put those two window events in a driver of your own for the time being |
Yeah it seems like a small driver can take care of this. Moreover, I think we should limit the DOM driver to only the DOM elements and DOM events. There are many more browser related APIs but those can have their own drivers. Even HTML rendering was moved out of the DOM driver, into HTML driver. |
@issuehuntfest has funded $40.00 to this issue. See it on IssueHunt |
###--------------------------------------------------------### feat(dom): window driver for events Window driver following examples set in dom driver for domsource and etc. Has no documentation as it was metioned that this might go into repository of its own rather than official one at first. BREAKING CHANGE: none ISSUES CLOSED: cyclejs#568 ###--------------------------------------------------------###
###--------------------------------------------------------### feat(dom): window driver for events Window driver following examples set in dom driver for domsource and etc. Has no documentation as it was metioned that this might go into repository of its own rather than official one at first. BREAKING CHANGE: none ISSUES CLOSED: cyclejs#568 ###--------------------------------------------------------### s
###--------------------------------------------------------### feat(dom): window driver for events Window driver following examples set in dom driver for domsource and etc. Has no documentation as it was metioned that this might go into repository of its own rather than official one at first. BREAKING CHANGE: none ISSUES CLOSED: cyclejs#568 ###--------------------------------------------------------###
Certain events, like the mouse leaving the browser window, can only be captured on the
window
, see hereTherefore it would be convenient if you could do:
This would help to resolve cyclejs-community/cyclejs-sortable#12
The text was updated successfully, but these errors were encountered: