Skip to content

fix android function signature so is similar to ios and return feedback dialog in android#7

Open
davr59 wants to merge 13 commits into
codeparticle:masterfrom
davr59:master
Open

fix android function signature so is similar to ios and return feedback dialog in android#7
davr59 wants to merge 13 commits into
codeparticle:masterfrom
davr59:master

Conversation

@davr59

@davr59 davr59 commented Feb 11, 2020

Copy link
Copy Markdown
Contributor
  • Rearranged android function signature so is similar to ios
  • Feedback dialog is now returned in android you can check if dialog is already open

@nicolam1 nicolam1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PR Review: Fix Android Function Signature

Thanks for this PR -- aligning the Android and iOS function signatures is a good improvement for API consistency, and returning the feedback dialog on Android is a useful addition. I have a few concerns and suggestions:


1. Breaking Change: CommonJS to ES Module Export

The switch from module.exports = exports (CommonJS) to export { showDoorbellFeedback } (ES module) is a breaking change for any existing consumers using require():

// This pattern breaks with named ESM exports:
const doorbell = require("nativescript-doorbell.io");
doorbell.showDoorbellFeedback(...); // undefined

// Would need to become:
import { showDoorbellFeedback } from "nativescript-doorbell.io";
// or
const { showDoorbellFeedback } = require("nativescript-doorbell.io"); // may work depending on bundler

NativeScript projects have mixed CommonJS/ESM support depending on the bundler (webpack vs the native CLI). Please verify this works across supported configurations, or consider using both export styles for backward compatibility.

Since this is a version bump to 0.0.7, a breaking change may be acceptable, but it should at least be documented in a CHANGELOG or the PR description.


2. Unused viewController Parameter on Android

The Android branch now accepts viewController in its signature but never uses it:

showDoorbellFeedback = function (appId, appKey, viewController, properties = undefined) {
    // viewController is never referenced

I understand this is intentional for cross-platform API consistency, but it could confuse consumers who see the parameter and expect it to do something on Android. Consider:

  • Using an underscore prefix (_viewController) to signal it is intentionally unused.
  • Adding a brief JSDoc comment: @param _viewController - Unused on Android, included for API parity with iOS.

3. Asymmetric Return Value Between Platforms

On Android, you now return feedback.show(), which is great -- it lets callers check if the dialog is already open. However, the iOS branch does not return anything. If the goal is API consistency, iOS should also return the feedback object (or some meaningful value). As-is:

// Android: returns the result of feedback.show()
return feedback.show();

// iOS: no explicit return (returns undefined)
feedback.showFeedbackDialogInViewControllerCompletion(viewController, (error) => { ... });

Consider returning the feedback object on iOS too, or documenting that the return value differs by platform.


4. Gradle compile to implementation

Good change. The compile configuration was deprecated in AGP 3.0+ and removed in Gradle 7+. Switching to implementation is the right call. No issues here.


5. for...in Iteration on Properties

The for (let p in properties) pattern iterates prototype-chain properties too. While this was pre-existing and not introduced by this PR, it is worth noting for a follow-up -- using Object.keys(properties).forEach() or adding a hasOwnProperty check would be safer.


6. properties = null to properties = undefined

This is a subtle but good change -- undefined is more idiomatic for optional parameters since checking if (properties) works the same for both null and undefined, but undefined signals "no value provided" more precisely than null.


Summary

The core intent of this PR is solid, but the ESM export change is a potential breaking change that needs attention, and the viewController parameter being silently ignored on Android could use a clarifying comment. I would recommend addressing at least items 1 and 2 before merging.

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