Giter VIP home page Giter VIP logo

now's Introduction

Get NowJS

NowJS is a NodeJS module. The client javascript (now.js) is served by the NowJS server.

Go to Github or Download the tgz

Install From npm

npm install now

NowJS uses the excellent socket.io and node-proxy libraries and portions of sesame. json2.js is integrated in nowUtil.js

2 Step Setup

1. On the server

var httpServer = require('http').createServer(function(req, response){ /* Serve your static files */ })
httpServer.listen(8080);

var everyone = require("now").initialize(httpServer);
everyone.now.msg = "Hello World!";

2. On the client


<script type="text/javascript" src="http://localhost:8080/nowjs/now.js"></script>

<script type="text/javascript">
  now.ready(function(){
    // alerts "Hello World!"
    alert(now.msg);
  });
</script>

FAQ

Q: Can I pass in a callback or closure, for example, if the remote function is asynchronous??

A: Yes. This is 100% supported

Q: How do I use NowJS with Express?

A: Very easily. var app = express.createServer(); app.listen(3000); var everyone = require("now").initialize(app);

*Q: Error: " SyntaxError: Unexpected token " / Can I statically host the now.js file?

A: On the client side, make sure you link to now.js like this

 <script src="http://myserver:myport/nowjs/now.js"></script>

You do not need to host the file /nowjs/now.js. It is automatically hosted by the NowJS using the http server you pass into the .initialize(...) in your server code. If you choose to host now.js yourself, you can, but do not use the version in github repo you MUST save the file at http://myserver:myport/nowjs/now.js and host that, because it is automatically configured for your server.

Further Reading

Now that you have NowJS, try the NowJS User Manual and Quick Chat Example

Have more questions? Please contact us: Email: [email protected]

IRC: #nowjs on freenode

Twitter: @NowJSTeam

now's People

Contributors

ericz avatar dshankar avatar swizec avatar andref avatar mcotton avatar graemeworthy avatar

Stargazers

Daza Grohovaz avatar

Watchers

Daza Grohovaz avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.