Skip to content
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

Eliminate js/window for nodejs compatibility #209

Closed
njordhov opened this issue Mar 5, 2016 · 14 comments
Closed

Eliminate js/window for nodejs compatibility #209

njordhov opened this issue Mar 5, 2016 · 14 comments

Comments

@njordhov
Copy link

njordhov commented Mar 5, 2016

As js/window is specific for browsers, for better compatibility with clojurescript on nodejs, consider using goog.global rather than js/window as in goog.global/WebSocket instead of (aget js/window "WebSocket")- or alternatively just js/WebSocket.

@ptaoussanis
Copy link
Member

Hi Terje, thanks for this.

Would ideally like to wait on a response from @theasp first at taoensso/encore#21 since he submitted the Node stuff and it's currently my understanding that he might already used Sente in this way without the need for any changes (?).

As I mentioned, I don't use Node myself so can't provide any guidance here. If any changes do turn out to be necessary, they'll likely need to come in the form of a PR.

In principle would be happy to make this as smooth as possible for Node users, would just like some confirmation before we adopt a particular plan.

Cheers :-)

@ptaoussanis
Copy link
Member

Also pinging @whamtet - any advice on this? Thanks!

@njordhov
Copy link
Author

njordhov commented Mar 6, 2016

Thanks Peter. Also note js/clearInterval and js/setTimeout are available both in browsers and nodejs. The special js namespace is bound to the global for nodejs and window for browsers, so neitherjs/window nor goog.global are required to access properties of the global object.

@ptaoussanis
Copy link
Member

Um, okay- something odd definitely going on. All trace of both issues seems
to be gone and Terje's GitHub page is 404'ing.

Perhaps he deleted his account and GitHub auto-kills all issues a deleted
user created?

Let's give it some time, maybe they're just having a temporary problem.

Will open a fresh issue so long.

On Sat, Mar 5, 2016 at 12:54 PM, Terje Norderhaug notifications@github.com
wrote:

As js/window is specific for browsers, for better compatibility with
clojurescript on nodejs, consider using goog.global rather than js/window
as in goog.global/WebSocket instead of (aget js/window "WebSocket") - or
alternatively just js/WebSocket.


Reply to this email directly or view it on GitHub
#209.

Peter Taoussanis
ptaoussanis@taoensso.com
taoensso.com https://www.taoensso.com

@whamtet
Copy link
Collaborator

whamtet commented Mar 6, 2016

Mysterious,

ok. Could try again in the morning. From what I can tell the js/window
references are only in sente.cljx and lie on the client side. Do we need
to get rid of them?

Matt

On 6 March 2016 at 21:24, Peter Taoussanis notifications@github.com wrote:

Um, okay- something odd definitely going on. All trace of both issues seems
to be gone and Terje's GitHub page is 404'ing.

Perhaps he deleted his account and GitHub auto-kills all issues a deleted
user created?

Let's give it some time, maybe they're just having a temporary problem.

Will open a fresh issue so long.

On Sat, Mar 5, 2016 at 12:54 PM, Terje Norderhaug <
notifications@github.com>
wrote:

As js/window is specific for browsers, for better compatibility with
clojurescript on nodejs, consider using goog.global rather than js/window
as in goog.global/WebSocket instead of (aget js/window "WebSocket") - or
alternatively just js/WebSocket.


Reply to this email directly or view it on GitHub
#209.

Peter Taoussanis
ptaoussanis@taoensso.com
taoensso.com https://www.taoensso.com


Reply to this email directly or view it on GitHub
#209 (comment).

@whamtet
Copy link
Collaborator

whamtet commented Mar 6, 2016

Ok, sure. Would you like me to put in a pr for it?
On 6 Mar 2016 9:24 pm, "Peter Taoussanis" notifications@github.com wrote:

Um, okay- something odd definitely going on. All trace of both issues seems
to be gone and Terje's GitHub page is 404'ing.

Perhaps he deleted his account and GitHub auto-kills all issues a deleted
user created?

Let's give it some time, maybe they're just having a temporary problem.

Will open a fresh issue so long.

On Sat, Mar 5, 2016 at 12:54 PM, Terje Norderhaug <
notifications@github.com>
wrote:

As js/window is specific for browsers, for better compatibility with
clojurescript on nodejs, consider using goog.global rather than js/window
as in goog.global/WebSocket instead of (aget js/window "WebSocket") - or
alternatively just js/WebSocket.


Reply to this email directly or view it on GitHub
#209.

Peter Taoussanis
ptaoussanis@taoensso.com
taoensso.com https://www.taoensso.com


Reply to this email directly or view it on GitHub
#209 (comment).

@ptaoussanis
Copy link
Member

@TerjeNorderhaug Hi Terje, could you please clarify: you're trying to use Sente from Node as a server (not client), and you're running into errors with js/window, etc.? Could you possibly include a reproducible example?

Please note that Sente currently supports Node on the server end but not the client end.

Does that make sense?

@njordhov
Copy link
Author

njordhov commented Mar 7, 2016

The Terje's GitHub page is 404'ing related issues was caused by a github bot flagging me as a bot, for no obvious reason.

@whamtet
Copy link
Collaborator

whamtet commented Mar 7, 2016

Quick! The bots are revolting! What was the problem you had with js/
window on node?
On 7 Mar 2016 1:41 pm, "Terje Norderhaug" notifications@github.com wrote:

The Terje's GitHub page is 404'ing related issues was caused by a
github bot flagging me as a bot, for no obvious reason.


Reply to this email directly or view it on GitHub
#209 (comment).

@xcthulhu
Copy link

This isn't just a node.js thing ; it effects slimerjs and phantomjs and interferes with using those systems for unit testing.

Likewise, it would be convenient if node.js could be a client, too....

@xcthulhu xcthulhu mentioned this issue Mar 28, 2016
@ptaoussanis
Copy link
Member

Just to clarify: Sente was initially a :clj server + :cljs client since that's what I needed myself, and it was a place to start.

The node.js client work prompted a small refactor which added support for :cljs servers too.

So as of today we have support for #{:clj :cljs :node} servers and #{:cljs} clients.

Some further refactoring will be necessary to add support for :clj clients and/or :node clients. Does that make sense?

I don't have a particular need for either of these myself and have some other priorities, so won't be able to handle these myself - but PRs would be welcome :-)

@xcthulhu
Copy link

Some further refactoring will be necessary to add support for :clj clients and/or :node clients. Does that make sense?

Sure; but I was just saying that there's other headless javascript environments besides node that don't have js/window besides node.

Personally, I don't have any pressing need for a :clj client (or a headless :cljs client beyond merely unit testing).

IMO, a refactor for headless :cljs would be easier than a :clj refactor ; I have admittedly been scared to refactor this code in the past, since without unit tests I wasn't sure if I was breaking things.

@DaveWM
Copy link
Contributor

DaveWM commented Jul 10, 2016

Hey guys, I've submitted a PR to allow nodejs clients. It might also enable nodejs servers, but I haven't tested that.

@ptaoussanis
Copy link
Member

Resolved with #243

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

No branches or pull requests

5 participants