Skip to content

#86 Fix singletone class initialisation #87

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

Merged
merged 4 commits into from
May 19, 2021

Conversation

Romick2005
Copy link
Contributor

Also take care of start stop Observing issue on metro bundler restart/reload/hot-reload.

@zxcpoiu
Copy link
Member

zxcpoiu commented May 19, 2021

@Romick2005

So you do not have init multiple times after this PR?

@Romick2005
Copy link
Contributor Author

Actually init called multiple times, but initPrivate only ones. Also on multiple call of init the returning result is same initialised only one time object. But generally this PR implements real singletone pattern.

@zxcpoiu
Copy link
Member

zxcpoiu commented May 19, 2021

About startObserving and stopObserving, would you please remove them and treat it as your own workaround in your private branch?

I don't think to ignore stopObserving when debug is a valid solution here.

Reload process has causes similar issues around different libs ( like mis-created multiple instances for react-native-webrtc, IIRC ), given that the reload only happens on DEBUG mode only, and we can not assure that the behavior is a bug or whether it will change in the future or not, not to say there are different algorithms / fallbacks / Engines there ( ex: full reload / HMS Fast Refresh...etc ), I prefer not to add this for general usages. Personally, I only find Fast Refresh useful when I'm tweaking UI stuff, if the test is related to native library, I always did a clean restart ( swipe out ) to prevent any reload-caused issues.

I think the more appropriate way would be needing an event api like onRefresh or onReload for the native side provided by React Native, and user can config them to reset some states.

Copy link
Member

@zxcpoiu zxcpoiu left a comment

Choose a reason for hiding this comment

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

  1. remove stopObserving workaround for refresh, keep this PR simple and could be discussed in another PR

  2. remove unused / commented debugging logs

-(instancetype) initPrivate {
self = [super init];
if (self) {
// Initialization code here.
Copy link
Member

Choose a reason for hiding this comment

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

above should only change the function name, instead making a mess diff

@zxcpoiu
Copy link
Member

zxcpoiu commented May 19, 2021

@jonastelzio @danjenkins

Hello, would you mind to take a look if this solves your problem described in #85?

@zxcpoiu zxcpoiu merged commit c299bae into react-native-webrtc:master May 19, 2021
@zxcpoiu
Copy link
Member

zxcpoiu commented May 19, 2021

Thanks @Romick2005
I just fix the style to match with the current code base, sorry to push to your branch directly, but I think it's more efficient.
If you want to adjust / fix the style, feel free to send another PR, thanks!

@zxcpoiu
Copy link
Member

zxcpoiu commented May 19, 2021

Since this an open source, so it would be better to follow the current code base's style, and makes minimal changes in a single PR.

But fire a PR to adjust them is acceptable for sure

@Romick2005
Copy link
Contributor Author

Thank you @zxcpoiu, it's just styling, so never mind. No worries I am ok with this, until it works as expected :).

zxcpoiu added a commit that referenced this pull request May 20, 2021
3e7f1a8 misc: normalize package.json  ( zxcpoiu 2021-05-20 01:50:13 -0700)
c299bae #86 Fix singletone class initialisation (#87)  ( Romick2005 2021-05-19 11:37:06 +0300)
54356e0 release 3.2.0  ( zxcpoiu 2021-04-17 02:12:48 +0800)
99feae8 feat: add typescript support  ( dayze 2021-02-23 11:36:48 +0100)
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.

2 participants