melloware / react-logviewer

React Lazy LogViewer
https://melloware.github.io/react-logviewer/
Mozilla Public License 2.0
45 stars 10 forks source link

if it possible to extract data provider out of component? #32

Open timzaak opened 2 months ago

timzaak commented 2 months ago

I use MQTT to get log line by line, it's not websocket nor http.

it would be nice if the api look like:


interface LazyLogController {
  newLine(lines:[]string) => void
  end() => void
  start() => void
  error() => void
}

const ref = userRef<LazyLogController>()

useEffect(() => {
   ref.current?.start()
   ref.current?.newLines(['test1','test2'])
   // ...
}, [])

<LazyLog ref={ref} follow>
melloware commented 2 months ago

PR's are welcome @timzaak. I forked this library because it had gone dead and had a bunch of bugs.

melloware commented 2 months ago

It looks like MQTT supports websocket?

https://www.hivemq.com/blog/mqtt-essentials-special-mqtt-over-websockets/

timzaak commented 2 months ago

Yes, but mqtt.js API has different API。

melloware commented 2 months ago

@timzaak are you interested in creating a PR for this feature?

timzaak commented 2 months ago

@timzaak are you interested in creating a PR for this feature?

ihave tried,but this would break api compatible(move state manager outside of component,user solve fetch data themselves,provide method to render lines)