Skip to content

Commit

Permalink
Merge pull request #2 from hotwired/incorporate-stimulus-polywork
Browse files Browse the repository at this point in the history
Update iOS JavaScript shim
  • Loading branch information
jayohms authored Sep 12, 2023
2 parents 84d6b06 + 184ea65 commit 3f8e6a0
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Source/strada.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class NativeBridge {
constructor() {
this.supportedComponents = []
document.addEventListener("web-bridge:ready", () => window.webBridge.setAdapter(this))
document.addEventListener("web-bridge:ready", () => this.webBridge.setAdapter(this))
}

register(component) {
Expand All @@ -27,8 +27,8 @@
}

notifyBridgeOfSupportedComponentsUpdate() {
if (window.webBridge) {
window.webBridge.adapterDidUpdateSupportedComponents()
if (this.isStradaAvailable) {
this.webBridge.adapterDidUpdateSupportedComponents()
}
}

Expand All @@ -38,8 +38,8 @@

// Reply to web with message.
replyWith(message) {
if (window.webBridge) {
window.webBridge.receive(message)
if (this.isStradaAvailable) {
this.webBridge.receive(message)
}
}

Expand All @@ -57,6 +57,14 @@
postMessage(message) {
webkit.messageHandlers.strada.postMessage(message)
}

get isStradaAvailable() {
return window.Strada
}

get webBridge() {
return window.Strada.web
}
}

window.nativeBridge = new NativeBridge()
Expand Down

0 comments on commit 3f8e6a0

Please sign in to comment.