uebersicht icon indicating copy to clipboard operation
uebersicht copied to clipboard

refreshFrequency in jsx for individual files

Open crackonosh opened this issue 6 years ago • 3 comments

I have a bar widget with few custom components. Whole bar is loaded from index.jsx file thanks to importing those individual components inside of file:

import {
  Battery,
  Time,
  Workspaces,
  Playing,
  FocusedApp,
  WifiStatus
} from './src/index.jsx'

While src/index.jsx looks like this.

export {default as FocusedApp } from './focusedApp.jsx';
export {default as Battery } from './battery.jsx';
export {default as Playing } from './playing.jsx';
export {default as Time } from './time.jsx';
export {default as Workspaces } from './workspaces.jsx';
export {default as WifiStatus } from './wifiStatus.jsx';

Whole bar is refreshed every second due to ↓command in the root file

export const refreshFrequency = 1000;

I've tried to remove this line and add it to those components itself, because not all parts of this widget have to be refreshed every second and some needs it. But my attempt at this wasn't successful.

Is there any way to refresh individual parts of the widget only and not the whole file? I somehow think it's because of the way the widget is written, so I'm leaving link to github repo of this widget for further details.

crackonosh avatar Dec 03 '18 07:12 crackonosh

Unfortunately this use case is not supported yet. Widgets don't really work as self contained react components, mostly because of the way they integrate with the rest of the app

felixhageloh avatar Jan 28 '19 18:01 felixhageloh

can I ask what your use-case is? Specifically, why are you importing them into one 'master' widget instead of leaving them as individual widgets?

felixhageloh avatar Jan 28 '19 18:01 felixhageloh

The reason is that not all parts of widget has to be refreshed every time others are. For example: wifi name should refresh once every 10s instead of clock which has to be refreshed every second. The reason why is it imported into the master widget is that I've forked the bar from other guy's repo and just went with it (and thought that it should be in one 'master' if it's still part of the bar). Moreover because it's .jsx instead of cofeescript with which I have no experience.

crackonosh avatar Jan 28 '19 18:01 crackonosh