usage sample
This commit is contained in:
parent
0138af71c0
commit
34dd2172c7
@ -1,18 +1,20 @@
|
|||||||
import { fw } from 'rage-fw-cef'
|
import { fw } from 'rage-fw-cef'
|
||||||
import { useEffect } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
const [data, setData] = useState('')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fw.event.register('customCefEvent', ([test]) => {
|
fw.event.register('customCefEvent', ([test]) => {
|
||||||
console.log(test)
|
setData(test)
|
||||||
|
return 'response from cef'
|
||||||
return ''
|
|
||||||
})
|
})
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h1>Hello World!</h1>
|
<h1>Hello World!</h1>
|
||||||
|
<h2>{data}</h2>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import { fw } from 'rage-fw-client'
|
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.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!'
|
return 'Hola from client!'
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
declare module 'rage-fw-shared-types' {
|
declare module 'rage-fw-shared-types' {
|
||||||
export interface RageFW_ICustomClientEvent {
|
export interface RageFW_ICustomClientEvent {
|
||||||
customClientEvent(greetings: string): string
|
customClientEvent(greetings: string): Promise<string>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RageFW_ICustomServerEvent {
|
export interface RageFW_ICustomServerEvent {
|
||||||
|
Loading…
Reference in New Issue
Block a user