angular-fullstack / generator-angular-fullstack

Yeoman generator for an Angular app with an Express server
https://awk34.gitbook.io/generator-angular-fullstack
6.12k stars 1.24k forks source link

Create new end point but is not Syncs in realtime across clients #1871

Closed gkio closed 8 years ago

gkio commented 8 years ago
Item Version
generator-angular-fullstack x.x.x
Node x.x.x
npm x.x.x
Operating System OS X 10 / Windows 10 / Ubuntu 15.10 / etc
etc etc
Item Answer
Transpiler Babel
Markup HTML
CSS SCSS
Router ngRoute
Build Tool Gulp
Client Tests Jasmine
DB MongoDB
Auth Y
etc etc

i just created new endpoint and added input and submit what else i have to do to make it Sync in realtme its works normal but its not syncing

Koslun commented 8 years ago

I am not sure what exactly the issue is. Could you outline a little bit more on what you did or give a simplified example of "it not syncing in realtime across clients but still working normally"?

Are you updating one client and not directly seeing the change in the second client?

Please also fill out what version of the generator, node, npm and OS you're using.

gkio commented 8 years ago

My steps


1st step

created new endpoint with

yo angular-fullstack:endpoing chat

2nd step

on models of server removed name and info and added name message and time

{name: String,message:String,time:String,active:Boolean}

3rd step

on view added input if loggedin and view and in main controller added sendMessage like sendThings just with the name of user time and message but its not work like things


How its works

i add an message on input and its get it via ng-model and the curretUser and the localtime then its send to db but when i press send its post to /? and its refresh and giving me the data but its not do it Async without refresh and dont give me the message without refresh on other client


Koslun commented 8 years ago

So you're making some kind of chat client?

As you might know you'll have to use sockets for that. Can't tell if you chose to add sockets to your application when you generated it but you probably should have. Taking it that you're sending the messages to be saved using the regular express API and mongoose methods, but you'll have to establish some kind of socket connection to continuously update the chat with messages pushed from the server. As the alternative is either refreshing like you're doing or constantly polling for new messages, neither a very good alternative for chats.

Think it's such a common use-case that there should be lots of blog posts, stackoverflow posts and other sites with examples. Should otherwise be pretty straight forward if you just understand how sockets work.

So I would simply point you to Google it.