usage sample
This commit is contained in:
parent
0138af71c0
commit
34dd2172c7
@ -1,18 +1,20 @@
|
||||
import { fw } from 'rage-fw-cef'
|
||||
import { useEffect } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
function App() {
|
||||
const [data, setData] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
fw.event.register('customCefEvent', ([test]) => {
|
||||
console.log(test)
|
||||
|
||||
return ''
|
||||
setData(test)
|
||||
return 'response from cef'
|
||||
})
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>Hello World!</h1>
|
||||
<h2>{data}</h2>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
import { fw } from 'rage-fw-client'
|
||||
|
||||
fw.event.register('customClientEvent', ([greetings]) => {
|
||||
fw.browser.registerBrowser(mp.browsers.new('package://cef/index.html'))
|
||||
|
||||
fw.event.register('customClientEvent', async ([greetings]) => {
|
||||
fw.system.log.info(greetings)
|
||||
|
||||
fw.player.triggerBrowser('customCefEvent', ['str'])
|
||||
const data = await fw.player.triggerBrowser('customCefEvent', ['str'])
|
||||
fw.system.log.info(`CEF RESPONSE: ${data}`)
|
||||
|
||||
return 'Hola from client!'
|
||||
})
|
||||
|
@ -1,6 +1,6 @@
|
||||
declare module 'rage-fw-shared-types' {
|
||||
export interface RageFW_ICustomClientEvent {
|
||||
customClientEvent(greetings: string): string
|
||||
customClientEvent(greetings: string): Promise<string>
|
||||
}
|
||||
|
||||
export interface RageFW_ICustomServerEvent {
|
||||
|
Loading…
Reference in New Issue
Block a user