sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

Dynamic Data : Problem with unregisterAvailableSourcesChanged

Open BraunJonathan opened this issue 8 years ago • 7 comments

Category

  • [x] Question
  • [ ] Typo
  • [x] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

When i call the unregisterAvailableSourcesChanged method from the dynamicDataProvider object, the calback provided as argument should not be called anymore...

Observed Behavior

It seems to me that calling unregisterAvailableSourcesChanged does not unregister the callback...

Steps to Reproduce

I've got a page with several same webparts which all are providers and consumers of dynamic data for each other...

On my react component in the componentDidMount method i call the registerAvailableSourcesChanged with a callback. On my componentWillUnmount method i call the unregisterAvailableSourcesChanged with the same callback.

My callback stays registered somewhere and each time i got back on the page, more callback are registered...

In the following example, props.context is the webpart context... I have the same webpart twice in the same page and the webpart implements IDynamicDataCallables

public componentDidMount() {   
  this.props.context.dynamicDataProvider.registerAvailableSourcesChanged(this.registerDynamicDatasources.bind(this));
  }

public componentWillUnmount(){
  this.props.context.dynamicDataProvider.unregisterAvailableSourcesChanged(this.registerDynamicDatasources.bind(this));
}

private registerDynamicDatasources() : void {
  console.log("register dynamic datasources " + this.props.context.instanceId);
}

On the real code, the registerDynamicDatasources method gets all available sources to connect to them...

Thanks for your contribution! Sharing is caring.

BraunJonathan avatar Oct 09 '18 15:10 BraunJonathan

testDynamicData.zip You can find here a sample webpart to reproduce the problem. You juste have to put the webpart twice on a site and look in the console on the number of logs looking like "TEST register dynamic datasources" when leaving and coming back on the page It is even worse when you leave the page to another site on the tenant.

Maybe ido not do things the right way, if so, please tell me what is wrong with my code ;-)

BraunJonathan avatar Oct 10 '18 07:10 BraunJonathan

Thanks @BraunJonathan, we'll have a look at this for getting it fixed/solved by GA. Thanks also on providing the sample solution as that help on the investigation.

VesaJuvonen avatar Oct 11 '18 08:10 VesaJuvonen

This should be now solved with the GA release, but we would appreciate your input on confirming that.

VesaJuvonen avatar Nov 20 '18 18:11 VesaJuvonen

Hi @VesaJuvonen Thanks for having a look at my problem but it seems the problem is still here... I upgraded the webpart i provided in 1.7 and did the test again andmy logs are still growing after each navigation... Maybe i'm doing something wrong into my code...

BraunJonathan avatar Nov 21 '18 15:11 BraunJonathan

Thanks, @BraunJonathan for coming back on this. If the issue is still with the 1.7, then the planned fix was not successful and we'll have a look on this.

VesaJuvonen avatar Dec 11 '18 17:12 VesaJuvonen

@BraunJonathan - Thanks for reporting this issue. This issue should have been fixed. I just double checked and see it works as expected. Can you please retry?

I'm closing the issue. Please feel free to open a new one, if you still see the issue.

srideshpande avatar Sep 27 '19 17:09 srideshpande

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 26 '20 12:01 msft-github-bot