-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Improve beforeload event #338
Comments
Feedback of @brodybits on this was:
A synchronous callback would be preferable, but that needs to be technically possible in Android's and iOS's WebView implementation, because the callback may take some time (because it involves a Javascript invocation). And then, regarding
|
I'm struggling to see how to use this with Ionic 4. How does one call the callback function in the beforeload event handler when using the new .subscribe style way of dealing with events? browser.on("beforeload") .subscribe( (ev: InAppBrowserEvent) => { The event is being fired as I see the url in the console - but the above wont build - I just guessed with the _loadAfterBeforeload function but it doesn't work. How do I call the callback to continue loading the url in this event? |
In the example's |
Thanks - but where do I reference this second parameter in the above code? |
Assuming you're using typescript, I would suppose it to be something like: browser.
on("beforeload").
subscribe( (ev: InAppBrowserEvent, callback: (url: string) => void ) => {
console.log(ev.url);
callback(ev.url);
}, err => { }); For people using typescript, I guess it would be useful to annonate the type for this callback. |
Thanks so much for this, I think we're close! - unfortunately I see this error now: Argument of type '(ev: InAppBrowserEvent, callback: (url: string) => void) => void' is not assignable to parameter of type '(value: InAppBrowserEvent) => void'. Any ideas? |
Still not managing to get this working. There is no mention of it in the types.d.ts file which I think is why it's triggering the error. If I use // @ts-ignore it bypasses the error but then I get a javascript error in the console when running in the simulator. I'm wondering if the beforeload callback is working in the current version? Many thanks. |
In #276 (CB-14188) the
beforeload
event was added.This event currently uses the same callback mechanism as other events, but it is different in one important aspect: instead of just notifying that something happened, it expects an action to be called. It would be good to allow a synchronous callback instead.
The text was updated successfully, but these errors were encountered: