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

[WIP]: Change of behavior in ObservableMap.replace #2255

Closed
wants to merge 153 commits into from

Conversation

Lmzd
Copy link

@Lmzd Lmzd commented Jan 9, 2020

Issue #2253

  • Adding test to reproduce error in v4

mweststrate and others added 30 commits August 14, 2018 15:32
…ow_mobx4

Update typings to allow flow to take async generators - async function* - MobX 4
* decorate - compose decorators for a single prop

- Reduce multiple decorators to a single decorator
- Added a test for multiple decorators (@action + custom) on a function property
- Added a test for multiple decorators (@observable + @serializable) on
  a regular property
- Added a usage example in readme under `decorate` section

* delete package-lock

* doc: update README

- Change caveat note about docorators composition as suggested in
  mobxjs#1652 (comment)
- Add decorators application order

* Update README.md
…orator-mobx4

decorate - compose decorators for a single prop (mobx4)
Decorate: Allow modifier when strict (MobX 4)
…side a computed value (mobxjs#1706)

* make allowStateChanges allow changes inside computed value

in order to fix MST mobxjs/mobx-state-tree#967

* added allowStateChangeInsideComputed

* added unit test

* small unit test error

* safer implementation

* Alternative solution

* Revert "Alternative solution"

This reverts commit e15bc78.

* improve unit test

* Changed to more predictable restoration
@mweststrate
Copy link
Member

mweststrate commented Jan 13, 2020 via email

@urugator
Copy link
Collaborator

urugator commented Jan 13, 2020

intercepting a single key beying re-added would effectively result in the loss of that key in the map?

Seems reasonable to me.
If I follow correctly, given the examples above, the results will be:

{ 3:3, 2:2 }
{ 1:1, 4:4, 5:5, 2:20 }

@Lmzd does that work for you or your use case?

For the next major I would consider using single replace interception event, rather than invoking set/delete for individual elements.
Currently there is a problem that the interceptor can access a map which is in inconsistent/unknown state ... so eg. you can't decide about interceptor outcome by inspecting current map.
Potentially cou can even break the operation by calling map methods during interception.
Same is probably true for other "complex" operations (clear/merge/...)

@Lmzd
Copy link
Author

Lmzd commented Jan 13, 2020

@urugator I implement those 2 tests in test/base/map.js, unsurprisingly they failed.

Can you check if the tests have the good logics please ?

https://github.com/Lmzd/mobx/blob/83f48bde95ac4f495abf596015dee9185da30fe3/test/base/map.js#L837-L883

test/base/map.js Outdated Show resolved Hide resolved
test/base/map.js Outdated Show resolved Hide resolved
test/base/map.js Outdated Show resolved Hide resolved
@urugator
Copy link
Collaborator

urugator commented Jan 14, 2020

Omg, I haven't realized that set are actually 2 different events, so you can actually prevent addition/update individually... that makes it even more complicated, I suppose? Eg. previously cancelled delete (during "clear"), can change the event of following set (from add to update)...?

@danielkcz
Copy link
Contributor

@Lmzd Are you able to finish this soon? Thing is I want to move ahead with #2248 which means a lot of files will change place so I don't want to do that with a lot of elaborate PR open.

@Lmzd
Copy link
Author

Lmzd commented Jan 21, 2020

Hi @FredyC , I've got some local changes but this is not good at this point (it breaks some of the #1980 observableMap tests) so IMO you can move ahead with #2248. I will rebase my work on the future "real" master branch.

@danielkcz danielkcz changed the base branch from mobx4-master to master January 23, 2020 15:08
@danielkcz danielkcz changed the base branch from master to mobx4-master January 23, 2020 15:09
@danielkcz
Copy link
Contributor

danielkcz commented Jan 23, 2020

@Lmzd The PR just went through so you need to rebase your work onto a master and there is src/v4 and test/v4 where you should do changes.

@Lmzd Lmzd changed the base branch from mobx4-master to master January 26, 2020 18:28
@Lmzd
Copy link
Author

Lmzd commented Jan 26, 2020

I think master does not have master-v4 commit history so that's why I have all those commit. It could not have commit reconciliation ...

@Lmzd
Copy link
Author

Lmzd commented Jan 26, 2020

Changes on *.md files are due to linter

@danielkcz
Copy link
Contributor

I am kinda surprised you went this way, V4 branch history is totally different, but looks like you got it sorted out, so it's fine. We will squash when merging, so it won't matter.

@danielkcz
Copy link
Contributor

So where are we with this? Can we move it forward somehow? The test is failing :/

A new issue #2274 for the replace has been filled and I wonder if this PR might fix it or break it even more. It might be worth adding that test case in this PR.

@mweststrate
Copy link
Member

Just did a quick check, this branch also fixes #2274, and it passes all v5 tests for me. @Lmzd could you share if there are any open items from your side?

@danielkcz
Copy link
Contributor

Based on the CI output, v4 tests are failing, v5 is fine because there are no changes to it in this PR.

@mweststrate
Copy link
Member

mweststrate commented Feb 10, 2020 via email

@mweststrate
Copy link
Member

To avoid double work: I think this one can be put [on hold] as the same issues will be investigated by @urugator, including tests / changes / fixes by this PR

@urugator
Copy link
Collaborator

urugator commented Feb 15, 2020

Closing in favor #2287

@urugator urugator closed this Feb 15, 2020
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