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

How to handle the version property in react or angular frontend? #86

Closed
LockTar opened this issue May 21, 2019 · 3 comments
Closed

How to handle the version property in react or angular frontend? #86

LockTar opened this issue May 21, 2019 · 3 comments

Comments

@LockTar
Copy link

LockTar commented May 21, 2019

Hi, we want some advice.

We are creating a new application that has a react frontend. In this frontend we have in example the details page of an entity. In example the entity customer. Let's say we can edit a field of a customer (in example phone number) so we have a popup that will let the user enter the new phone number. The phone number is pushed to the server with the latest version and command is executed.

But what then? Do we need to update the version on the client? Or are we refreshing the page? Or are we (re)loading the customer again so we get the latest version?
How are you guys doing this?

Thanks

@gautema
Copy link
Owner

gautema commented May 21, 2019

Hi.
If you are doing everything synchronous, the easiest is probably to return the new customer from the save action or do a get on the customer directly after the save has finished. You could just return the version number as well (or just increment version by one), but if there are side effects from the save, you often have to implement the same logic several places which I find to be more trouble than it's worth.

If things are asynchronous things get a bit harder. Then the client need to subscribe to events from the server. This can be done using websockets, signalr or similar tech to get updates as they happen.

I have used both options myself and giving events can be a nice way to notify that something has changed on the server by an other user as well. But it's more work.

Hope this helps a bit.

@LockTar
Copy link
Author

LockTar commented May 21, 2019

Thank you for the fast reply. We now implemented indeed the "refresh" option. So get the user again and update the field. Just like you would open the page. In this way you don't have to write client business logic for something that the server maybe already have done for you.

in example:
Update lastname of customer => dto object from server will return firstname, lastname and fullname/displayname (first and lastname combined)

We were also thinking about websockets or signalr but in a later fase of the application. Now first other priorities.

@gautema
Copy link
Owner

gautema commented May 23, 2019

Sounds good. I'm closing this as I hope you got answers to your questions. Just reach out again if theres any more questions.

@gautema gautema closed this as completed May 23, 2019
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