apache / apache/cordova-plugin-inappbrowser

Beforeload not working with TypeScript

Open
#561 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.1k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Description

# Bug Report

Using the plugin with Ioinic 4 using TypeScript, the beforeload second callback doesn't seem to work. The initial event is fired but then the link is never loaded because the second callback isn't fired.

Paid help required! We're happy to pay for help to get this issue resolved if it is a bug, or even just to help us get it working if we're using it incorrectly etc. The documentation doesn't seem to show how to use this with TypeScript syntax so we're at a bit of a loss. Any help much appreciated.

### What is expected to happen?

The second callback inside the beforeload event callback should be able to be fired to complete the link loading after some logic is performed within the main event callback function.

### What does actually happen?

An error is shown when building. If ts-ignore is used, an error shows in the JS console instead.

### Command or Code
`
browser.on("beforeload").subscribe( (ev: InAppBrowserEvent, callback: (url: string) =>string ) => {
console.log('before load fired');
// This function is fired as expected.
console.log(value.url);
// The following callback function shows an undefined error if ts-ignore is used, otherwise it fails to build.
callback(value.url);
}
,err=>{}
);
`

### Environment, Platform, Device
All.

### Version information
ionic/angular 4.6.2

## Checklist

- [x ] I searched for existing GitHub issues
- [x ] I updated all Cordova tooling to most recent version
- [x ] I included all the necessary information above

Contributor guide

Open the contributing guide

Research direction

The report names no repository files or tests; start by reproducing the beforeload subscription build error in the Ionic/TypeScript example and inspect the plugin's beforeload API and TypeScript declarations. Done means the second callback compiles, runs after the event logic, and allows the link to load without a console error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.