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

Add #send_back to the base controller

Merged
merged 4 commits into from Apr 4, 2020
Merged

Add #send_back to the base controller #7

merged 4 commits into from Apr 4, 2020

Conversation

privorotskii
Copy link
Contributor

@privorotskii privorotskii commented Apr 1, 2020

This PR relates to this issue and this post.

Should the issue be here, in this repo?

I hope, I understand this task correctly, let me know if something is wrong.

@@ -19,6 +19,10 @@ def initialize(action:, meta: {})
@meta = meta
end

def send_back(action, meta = @meta)
Copy link
Member

@ai ai Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need to copy origin @meta.

BaseController is a controller to process action (an object with a description of what to change in a database). Each action has meta (with unique ID and time when it was created).

@action and @meta here is an action from the client, which we should process.

action and meta in send_back() is an action, which server answer to client’s action.

By setting meta = @meta we will force our server’s response action to have the same ID, that the client’s action had. Because the server’s action will have the same ID, the client will ignore this new server’s action, because of client already have action with the same ID.

Copy link
Member

@ai ai Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def send_back(action, meta = @meta)
def send_back(action, meta = { })

Copy link
Contributor Author

@privorotskii privorotskii Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, got it now. So, I just take @meta's client ID and add it to passed meta as clients, to say Logux, that I want to send the action back to the client.

@ai
Copy link
Member

ai commented Apr 2, 2020

LGTM

cc @dsalahutdinov

@@ -22,6 +21,23 @@
end
end

describe '#send_back' do
subject(:send_back) { action_controller.send_back(back_action) }
Copy link
Collaborator

@dsalahutdinov dsalahutdinov Apr 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's check the case passing a meta, to ensure a result of meta composition with merge

Copy link
Contributor Author

@privorotskii privorotskii Apr 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I suggested that checking both cases would be redundant, so I changed existing spec without meta passing instead of adding another one with passed meta. Let me know if I need to check both of these cases.

Copy link
Collaborator

@dsalahutdinov dsalahutdinov left a comment

👍

@dsalahutdinov dsalahutdinov merged commit 083dce2 into logux:master Apr 4, 2020
1 check passed
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

Successfully merging this pull request may close these issues.

None yet

3 participants