添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Description
I'm working on a custom widget, derived from the map-widget where I include the alarm-data of the aliased devices.
For this purpose, I'm using the deviceService (to get all the user devices' ids) and the http-service (to call the alarm api-endpoint).
I've added my code into the onInit-function as well as the onDataUpdated-function.
The relevant parts of the code look as follows (I've simplified the relevant code to a minimum which still causes the strange behavior):

self.onDataUpdated = function() {           
    let defaulthttpconfig={
        ignoreLoading:false,
        ignoreErrors:false,
        resendRequest:false
    customerId={entityType:'CUSTOMER',id:self.ctx.currentUser.customerId};
    let pl = new self.ctx.pageLink(100,0,null,null);
    const uu='/api/alarm/DEVICE/';
    const bb='?pageSize=100&page=0';
   // nested subscriptions
   const outer$=deviceService.getUserDevices(pl,'MYProfile',defaulthttpconfig);
   outer$.pipe(
        self.ctx.rxjs.switchMap( data => {
            //return self.ctx.rxjs.of(data); // <-- no refresh triggered 
            return http.get(uu+data.data[0].id.id+bb,defaulthttpconfig);  // <--refresh triggered
    ).subscribe(console.log,console.error); 

Surprisingly, this nested subscription triggers a refresh of the widget as seen in the following gif:
This refresh propagates into the widget-types view which makes it hard to add new widgets because the edit-menu is refreshed every couple of seconds. See the next gif.

Is there any way to prevent this behavior?

Environment

  • OS: Win 10
  • ThingsBoard: PE 3.3.1
  • Browser: Chrome
  •