Skip to content

Commit cfc8231

Browse files
authored
DEVREL-2765: subscribing to selected variant changes (#36)
1 parent 8d21b6c commit cfc8231

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/examples/utilities.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,17 @@ export const Utilities = {
205205
)
206206
},
207207

208+
subscribeSelectedVariant: async () => {
209+
// Subscribe to variant selection changes on the component canvas
210+
const unsubscribe = webflow.subscribe('selectedvariant', (variant) => {
211+
console.log('Selected variant:', variant.name)
212+
console.log('Variant ID:', variant.id)
213+
})
214+
215+
// Stop listening after 10 seconds
216+
setTimeout(unsubscribe, 10000)
217+
},
218+
208219
getLaunchContext: async () => {
209220
const context = await webflow.getLaunchContext()
210221
console.log('Launch Context:', context)

0 commit comments

Comments
 (0)