DEV Community

loading...

Discussion on: Good Bye Web APIs

Collapse
wormss profile image
WORMSS • Edited

Is there a way to subscribe to changes on the server (long polling or websockets)?

Not yet, but it is on the road map.

Yeah, that is a MAJOR massive catch.. That pretty much turns this completely unusable for anything other than meaningless apps that that store a users data in a silo. EG, a note keeping app that doesn't have the ability to share notes between users.

Thread Thread
mvila profile image
Manuel Vila Author

@wormss , I think you misunderstood. Not being able to synchronize clients in real-time with web sockets doesn't mean there is no shared storage. It's no different than any web app, the backend stores data in a database, so any data can be shared between users.

Thread Thread
wormss profile image
WORMSS

If I am reading your example above correctly, "value" is synchronous, so it would never know if someone else has incremented it? So reading it client side will be wrong the moment someone else adds it.

Thread Thread
mvila profile image
Manuel Vila Author

The backend is stateless, so in the example, the counter is unique for each user. To share the counter among all users, the backend must save it in a database.

Thread Thread
wormss profile image
WORMSS

And again, I ask how the UI gets to know that it has changed.

Thread Thread
mvila profile image
Manuel Vila Author

When you execute a remote method on an object, the attributes of the object are automatically transported between the frontend and the backend. So, when you change an attribute in the backend, the change is reflected in the frontend.