Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing a class between Node.js and the browser

Tags:

node.js

If i have a class, what is the best way to share that class and use it in both the browser as well as Node.js?

For example a game that uses a 2D Vector math class on both the client-side and the node.js.

like image 361
Onedayitwillmake Avatar asked May 14 '26 03:05

Onedayitwillmake


1 Answers

NowJS is a pretty elegant way to share variables and functions between client JS and Node JS through an automatically sync'ed shared namespace.

There's also dnode, which the author comments on in response to a posting about NowJS here: http://news.ycombinator.com/item?id=2316079

like image 182
entropo Avatar answered May 15 '26 15:05

entropo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!