@goleo/bridge
v0.2.6
Published
Frontend bridge library for Goleo — communicate between web frontend and Go backend
Maintainers
Readme
@goleo/bridge
The frontend bridge library for Goleo applications.
Provides communication between your web frontend and Go backend.
Installation
npm install @goleo/bridgeUsage
import { initBridge, invoke, on, getOSInfo } from '@goleo/bridge'
// Initialize the bridge (connects to Go backend)
await initBridge()
// Call Go backend functions
const result = await invoke('greet', { name: 'World' })
console.log(result) // { message: "Hello, World! From Go backend." }
// Listen for backend events
const unsubscribe = on('backend:ready', (data) => {
console.log('Backend ready:', data)
})
// Use built-in functions
const osInfo = await getOSInfo()
console.log('OS:', osInfo.name, osInfo.arch)
// Cleanup
unsubscribe()API
initBridge(config?)- Initialize connection to Go backendinvoke(method, args?)- Call a Go backend functionon(event, callback)- Listen for backend events (returns unsubscribe function)off(event, callback)- Remove event listenergetOSInfo()- Get OS informationgetPlatformInfo()- Get platform informationgetArch()- Get CPU architecturegetEnv(key)- Get environment variableopenURL(url)- Open URL in default browserdisconnect()- Disconnect from backendisConnected()- Check connection status
