Page MenuHomePhabricator

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

Authored by tomek on Tue, May 7, 7:55 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, May 18, 5:14 AM
Unknown Object (File)
Fri, May 17, 2:26 PM
Unknown Object (File)
Fri, May 17, 12:45 PM
Unknown Object (File)
Fri, May 17, 10:34 AM
Unknown Object (File)
Mon, May 13, 12:37 PM
Unknown Object (File)
Sat, May 11, 10:08 PM
Unknown Object (File)
Sat, May 11, 8:22 PM
Unknown Object (File)
Fri, May 10, 9:28 AM
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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
18 ↗(On Diff #39892)

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

tomek requested review of this revision.Tue, May 7, 8:15 AM
marcin added inline comments.
native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
436 ↗(On Diff #39892)

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.Wed, May 8, 3:15 AM
native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
436 ↗(On Diff #39892)

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 ↗(On Diff #39892)

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.