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

Does express-vue support dynamically changeable data push to the DOM? #41

Closed
CyberFerret opened this issue Mar 1, 2017 · 2 comments
Closed

Comments

@CyberFerret
Copy link

Does express-vue bind the data variables so that changes are pushed to the DOM in real time?

For example, I have the code block in Node.js:

var myVar = 1;    

app.get('/', function(req, res){
  res.render('index', {
    data:  {
        displayVar: myVar
    },
    vue: {
        components: ['mycomp']
    }
  });
});

This displays '1' in my component view as expected.

However, I would expect that by Vue.js standards, if I updates myVar to say, myVar = 2 via a timed function elsewhere in my code, that {{ displayVar }} in my view would change to say '2'? At the moment the new result doesn't show unless I manually refresh the page.

Or do I have my understanding completely wrong of how express-vue is supposed to work?

@danielcherubini
Copy link
Collaborator

danielcherubini commented Mar 1, 2017

This is how a server side rendered website is supposed to act. If you want it to dynamically update the client you'll need something like websockets. A good place to start is socket.io

See server side rendered pages work like this.

The client asks the server for the view.
The server renders the view. Sends it to the client.
Done

If the client wants something else. It's either a new page request. Or a REST action.

So for instance let's say you have a button that tells the server that that variable is now 2.
You need a post request setup on the client and the view.

You can google how to do rest actions and apis. It's really straightforward.

Or if you want it dynamic on the client from the server you'll need a websocketor something like it

@danielcherubini
Copy link
Collaborator

To give more information..

If you want something dynamic on the client, then do everything in the .vue files.. you can find documentation on http://vuejs.org

but if you want say the client and the server to have the same information without reloading, then they need to communicate, either through a REST API, or via Websockets..

everything done on the client will be dynamic, thats the goal of this library, to have dynamic views using Vue.js, so everything on the client is dynamic, and then stuff on the server is static, so when a client requests a webpage, its sent in an initial state which you define.. then the client is dynamic from there.

this isn't a problem with the library, so I'm closing this

onebesky pushed a commit to onebesky/express-vue that referenced this issue Oct 5, 2017
…in-0.51.0

Update flow-bin to the latest version 🚀
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants