DEV Community

Discussion on: Good Bye Web APIs

 
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

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

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.