-
Notifications
You must be signed in to change notification settings - Fork 475
feat: Allow brownfield iOS apps to handle storage. #35
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
feat: Allow brownfield iOS apps to handle storage. #35
Conversation
7e36847
to
c8260fc
Compare
@krizzu: How are you testing RNCAsyncStorage? I had to patch diff --git a/lib/AsyncStorage.js b/lib/AsyncStorage.js
index 4769097..6c007d8 100644
--- a/lib/AsyncStorage.js
+++ b/lib/AsyncStorage.js
@@ -18,6 +18,7 @@ const {NativeModules} = require('react-native');
const RCTAsyncStorage =
NativeModules.AsyncRocksDBStorage ||
NativeModules.RNC_AsyncSQLiteDBStorage ||
+ NativeModules.RNCAsyncStorage ||
NativeModules.AsyncLocalStorage;
type ReadOnlyArrayString = $ReadOnlyArray<string>; |
c8260fc
to
af7c6c1
Compare
@krizzu: Also, it seems that in making it possible to run from Xcode, I broke Detox builds. Any suggestions here? |
af7c6c1
to
63310d2
Compare
Never mind. Figured out why Detox broke. 😁 |
For the first question: #37 |
@tido64 Your changes are already merged, so feel free to rebase. |
63310d2
to
70478df
Compare
@krizzu Thanks 👍 |
@krizzu Let me know how I can make this PR better 😉 |
@tido64 Great, thanks! I'm going to need a second pair of eyes on iOS code, but overall looks good. We could have some documentation about new feature - ideally in new Also, some tests would be good to check it too. |
@krizzu LGTM. I think we only need to add some tests and docs. 🤔 |
42d6597
to
fe8ceda
Compare
@krizzu @zhongwuzw I added docs and tests. Please have a look 😄 |
@tido64 Thanks! I'll have a look once I find a time later today |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @tido64 , thanks for your awesome work!
I left few comments/suggestion that I think would be great to consider.
Also, I might be missing here somewhere, but I assumed that this "delegation" would work as a "plugin" for iOS module, where you change underlying implementation of AsyncStorage - you provide "object" with methods named same as original AsyncStorage , so those would be used instead.
In here, I believe you created a delegate
in App delegate
for testing purposes, correct?
thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a look, @krizzu. I'll try to get to these within the week.
I'm not sure I follow your questions so bear with me 😄
- Yes, a delegate is basically just an object with named functions. The interface is usually defined by the one that will be calling it.
- The methods of
AsyncStorage
are never replaced. But it can be redirected to call the delegate instead. And if the passthrough property is set, the methods ofAsyncStorage
are still called. - In the test app, the
AppDelegate
implements this interface for testing purposes. In a normal app, usually another object would implement it.
9d6a0ad
to
5411c4c
Compare
Co-Authored-By: tido64 <4123478+tido64@users.noreply.github.com>
Co-Authored-By: tido64 <4123478+tido64@users.noreply.github.com>
5411c4c
to
3197ae1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Thanks you! 💪 🚀
Hi team, just a heads up that this breaks native linking via cocoapods, as the library is linked as There are two ways to move forward:
Let me know, I'd be happy to put up a PR |
The second approach also requires the current user of cocoa pod linking to update their Podfiles, so option 1 is less intrusive, even though cringe seeing the import from |
Sorry for not testing this thoroughly with Pods. Completely slipped my mind.
I’m for solution #2. Yes, it will break on upgrade but it’s the right thing to do and will be in line with Apple’s naming guidelines and what the community will expect.
Thanks for bringing it to our attention and fixing it ❤️
Sent from ProtonMail Mobile
…On Fri, Apr 12, 2019 at 17:21, Ullrich Schäfer ***@***.***> wrote:
The second approach also requires the current user of cocoa pod linking to update their Podfiles, so option 1 is less intrusive, even though crunch seeing the import from <react-native-async-storage...> [:neckbeard:]
—
You are receiving this because you were mentioned.
Reply to this email directly, [view it on GitHub](#35 (comment)), or [mute the thread](https://github.com/notifications/unsubscribe-auth/AD7rVnZtqlr7HhSr614dNyO8KtU6OvZwks5vgKRegaJpZM4bpmXH).
|
First, thank you, you just saved me. I spent the last hour trying to understand why the hell Xcode wasn't finding RNCAsyncStorageDelegate.h ... I manually implemented solution #1 and it's building everything as expected. That said, I vote for #2 as well. Although it is breaking on upgrade, it's the cleanest solution, imho. Thank again ! |
Okay, seems like we made a decision. |
Somebody correct me if I'm mistaken, but if you're using |
@krizzu @stigi Sorry, I got a little impatient since I broke this release. I've implemented the fix here: #75. I've checked that |
Summary: --------- Multiple people have reported that RNCAsyncStorage fails to build after #35. See #35 (comment), #73, and #74. After a little discussion, we agreed to rename the `.podspec` and the name of the Pod to be more in line with Apple's naming guidelines and the rest of the community. Unfortunately, this means that the next upgrade will break. I got a little impatient knowing that I broke the latest release so I went ahead and implemented the fix. Sorry if you've already started looking at this. Migration Plan: --------------- Even though `react-native link` will be able to link the new `.podspec`, it won't clean up existing entries. Please find your Podfile, and make the following changes: ```diff - pod 'react-native-async-storage', :path => '../node_modules/@react-native-community/async-storage' + pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage' ```
Summary: --------- Multiple people have reported that RNCAsyncStorage fails to build after #35. See react-native-async-storage/async-storage#35 (comment), #73, and #74. After a little discussion, we agreed to rename the `.podspec` and the name of the Pod to be more in line with Apple's naming guidelines and the rest of the community. Unfortunately, this means that the next upgrade will break. I got a little impatient knowing that I broke the latest release so I went ahead and implemented the fix. Sorry if you've already started looking at this. Migration Plan: --------------- Even though `react-native link` will be able to link the new `.podspec`, it won't clean up existing entries. Please find your Podfile, and make the following changes: ```diff - pod 'react-native-async-storage', :path => '../node_modules/@react-native-community/async-storage' + pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage' ```
Summary: --------- Multiple people have reported that RNCAsyncStorage fails to build after #35. See react-native-async-storage/async-storage#35 (comment), #73, and #74. After a little discussion, we agreed to rename the `.podspec` and the name of the Pod to be more in line with Apple's naming guidelines and the rest of the community. Unfortunately, this means that the next upgrade will break. I got a little impatient knowing that I broke the latest release so I went ahead and implemented the fix. Sorry if you've already started looking at this. Migration Plan: --------------- Even though `react-native link` will be able to link the new `.podspec`, it won't clean up existing entries. Please find your Podfile, and make the following changes: ```diff - pod 'react-native-async-storage', :path => '../node_modules/@react-native-community/async-storage' + pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage' ```
Summary:
Adds a delegate property to
RNCAsyncStorage
to allow custom handling of storage.Implements #33.
Test Plan:
To manually test the delegate, shake the Simulator (^⌘Z) and toggle
"Set AsyncStorage Delegate". Otherwise, tests for JS have been duplicated for
the native delegate.