usage sample

This commit is contained in:
Oleksandr Honcharov 2024-06-15 17:41:45 +03:00
parent 0138af71c0
commit 34dd2172c7
3 changed files with 12 additions and 7 deletions

View File

@ -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>
</> </>
) )
} }

View File

@ -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!'
}) })

View File

@ -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 {