Page MenuHomePhabricator

[native] Create a function that processes all the ops
ClosedPublic

Authored by tomek on May 7 2024, 7:55 AM.
Tags
None
Referenced Files
F3513112: D11921.id39990.diff
Sat, Dec 21, 10:33 PM
F3513111: D11921.id39892.diff
Sat, Dec 21, 10:33 PM
F3513098: D11921.id.diff
Sat, Dec 21, 10:33 PM
F3513091: D11921.diff
Sat, Dec 21, 10:33 PM
Unknown Object (File)
Sat, Dec 14, 8:19 PM
Unknown Object (File)
Sun, Dec 8, 2:19 AM
Unknown Object (File)
Nov 18 2024, 7:34 PM
Unknown Object (File)
Nov 18 2024, 4:38 PM
Subscribers

Details

Summary

Create a single vector where all the ops are stored and process them in a single transaction.
This function isn't ideal, but I have discovered a lot of ways of how it can't be implemented. I checked a lot of ideas from Internet, but I haven't found anything that compiles (mainly due to a fact that we're storing a vector of unique pointers - but avoiding the pointers also requires a lot of work).

https://linear.app/comm/issue/ENG-6004/wrap-all-store-operations-from-one-action-in-transaction

Depends on D11902

Test Plan

Modified redux-utils and used this function to process the drafts operations. Then created a draft, closed and reopened the app and checked if the modified draft was present.

Diff Detail

Repository
rCOMM Comm
Branch
transactions
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
18

This includes the other std::move https://en.cppreference.com/w/cpp/algorithm/move

tomek requested review of this revision.May 7 2024, 8:15 AM
marcin added inline comments.
native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
436

Perhaps we could create a hashmap in CommCoreModule constructor mapping from key string to a pointer to a store instance and just iterate here?

This revision is now accepted and ready to land.May 8 2024, 3:15 AM
native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
436

Considered this, but each store has a different type - these are all template classes. I haven't found a way of making it compile.

native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
436

The problem is that all the stores have different parents - each of them inherits from a template class with different type parameters, which means that there's no common parent class. Also, it would be more important if we would need to iterate in more than one place.