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

Fix/#155264394 added missing on error methods #14

Merged
merged 11 commits into from
Apr 2, 2018

Conversation

Arpit-Patel
Copy link
Contributor

No description provided.

Arpit Patel added 3 commits March 1, 2018 11:36
- added onError methods for TaplyticsNewSessionListener and SessionInfoRetrievedListener to the react wrapper
	- Updated build.gradle to match latest SDK version
@Arpit-Patel Arpit-Patel requested a review from VicV March 5, 2018 19:35
@@ -243,6 +246,9 @@ public void onNewSession() {
params.putBoolean("value", true);
sendEvent("newSession", params);
}
public void onError() {

Copy link
Member

Choose a reason for hiding this comment

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

do we need to send an event with the value of false here?

Copy link
Contributor

Choose a reason for hiding this comment

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

it should also be overriding onError()...

@Arpit-Patel you can open this file in Android studio and it will show you its errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see any errors in studio with it @VicV.
@jonathannorris I will add that

Copy link
Member

Choose a reason for hiding this comment

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

@VicV why doesn't this one have a promise like the other ones?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jonathannorris there is no promise because its just setting a listener.

@@ -283,6 +289,9 @@ public void sessionInfoRetrieved(HashMap hashMap) {

callback.resolve(resultData);
}
public void onError(HashMap hashMap) {
callback.resolve(null);
Copy link
Member

Choose a reason for hiding this comment

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

should we reject the promise?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jonathannorris not sure what rejecting the promise does inside of the react package. Need to ask @ajwootto about that.

@Arpit-Patel This should be resolved with an empty hashmap I believe

Copy link
Member

Choose a reason for hiding this comment

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

well rejecting the promise is basically the same as an error response.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I think this should probably reject with an error message

@@ -232,6 +232,9 @@ public void startNewSession(final Promise callback) {
public void onNewSession() {
callback.resolve(null);
}
public void onError() {
callback.resolve(null);
Copy link
Member

Choose a reason for hiding this comment

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

should we reject the promise?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should be overridden as well.

@Arpit-Patel Arpit-Patel requested a review from ajwootto March 5, 2018 21:00
Arpit Patel added 4 commits March 5, 2018 16:31
- Changed value to event.value since value is not declared
- Removed promise from _setTaplyticsNewSessionListener, since this is not explicitly called by user
public void onError() {
WritableMap params = Arguments.createMap();
params.putBoolean("value", false);
sendEvent("newSession", params);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to still emit this event on error? What if people are using the listener but ignoring the value?

Copy link
Contributor Author

@Arpit-Patel Arpit-Patel Mar 7, 2018

Choose a reason for hiding this comment

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

@ajwootto yeah you're right that doesn't make sense.
Would it be better to just use a promise and then use a then and catch in the index.js which also resolves and rejects? So that the user can know if setting failed or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

I dont think so because this is technically a "listener" which means it can be called many times at any time by the SDK.

Copy link
Contributor

Choose a reason for hiding this comment

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

One thing you could potentially do is change the DeviceEmitter listener function on the JS side to take two parameters, a "newSession" callback and an "onError" callback

@@ -77,7 +77,7 @@ Taplytics.setTaplyticsNewSessionListener = (listener) => {
Taplytics._setTaplyticsNewSessionListener()
Copy link
Contributor

Choose a reason for hiding this comment

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

could change this to take two "listeners" representing success and failure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I don't think its that useful anymore to even do anything on error cause setTaplyticsNewSessionListener on the sdk side is a very trivial operation. The onError call is really on useful when you're calling startNewSession, since many things can potentially go wrong.

@VicV VicV merged commit a8b4942 into master Apr 2, 2018
@hamzahayat hamzahayat deleted the fix/#155264394-added-missing-onError-methods branch March 12, 2021 17:00
hamzahayat added a commit that referenced this pull request Apr 23, 2021
* Refactored SDK to be more modular

* Removed TaplyticsProvider imports

* Removed unused and undocumented native methods

* Added _newSessionCallback native method and exported it as part of `setTaplyticsNewSessionListener` method

* Changed newSyncObject to take in NSDictionary

* Added getVariables and registerVaraiblesChangedListener methods and removed lodash and only added lodash.clonedeep

* Add library to gitignore and prettierignore

* Added extra line on ignore files

* Added push method types and cleaned up the push methods

* Removed old index files and added push types to index

* Fixed typo in console.error

* Fixed a bug caused by the event listeners not being initialized before they are triggered

* Export getRunningExperimentsAndVariations

* Reformatted android module, and fixed crash for newSyncObject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants