We have developed two SPFX webparts that communicate with each other and deployed them in SharePoint Online. We followed 'EventAggregator' sample to build these webparts and establish communication across them. We used spfx 1.4.1 framework (please refer to package.json file for reference). The communication between broadcaster and receiver webparts were working fine. However, since yesterday (24 Oct 2018) we found the communication is no longer working. It is important to specify that we did not make any changes to the code in our test environment before it ceased to work automatically.
Upon detailed analysis we observed that the context.eventAggregator property is coming 'undefined' which accounts for the issue. Please refer to the FilteredEventsListWebPart.ts.txt file and render event.
Receiver webpart file (TS)
FilteredEventsListWebPart.ts.txt
Package.JSON
package.json.txt
We expect that the context.eventAggregator property would not be undefined.
context.eventAggregator property is coming as undefined. This version of code was working until 23rd Oct. Since 24th the code is breaking due to the fact that context.eventAggregator property is undefined. Please note that this behavior is same in both the broadcaster and receiver webparts.
Please refer to the attached files that should be sufficient to analyze the issue.
@priyankocts the context.eventAggregator was a feature in ALPHA state and never made it to general availability state. The recommendation was to NOTuse it in production since it was experimental feature. Since it is an ALPHA feature it can be removed event from old version of the SPFx without warning.
There is a replacement for the event aggregator, but it is yet NOT officially released. Please have a look at that https://docs.microsoft.com/en-us/sharepoint/dev/spfx/dynamic-data
Again, the new dynamic data is also in PREVIEW and you should not use it in production until it is generally available.
@VelinGeorgiev Thanks for your reply.
Could you advise if we can use react-rxjs-event-emitter to achieve communication between webparts?
https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-rxjs-event-emitter
What's the best way to achieve this functionality until dynamic data is generally available?
@priyankocts the rxjs-event-emitter is just a sample and it is not production ready. However, you can align it to your needs and make it production ready, but I cannot guaranty that it will fully meet your needs since I created it as sample.
My recommendation is to wait until the dynamic data feature is generally available because this will be the only and officially supported way. If you can't wait you can use the rxjs as tactical solution until the dynamic data is available and then switch to it.
My recommendation is to wait until the dynamic data feature is generally available because this will be the only and officially supported way.
Per this thread, https://github.com/SharePoint/sp-dev-docs/issues/2711 it may be part of 1.7 release. Any confirmation if it will definitely be. Dynamic data is a cool feature and would love to utilize it for production if its confirmed for 1.7 release.
Yes, it should be part of 1.7 version, but it is never official until Microsoft announces it.
@patmill Do we have any tentative dates on when 1.7 will be released. It would help to communicate to our team on when they can expect an upgrade.
@patmill Do we have any tentative dates on when 1.7 will be released. It would help to communicate to our team on when they can expect an upgrade.
Any new updates on 1.7 release timelines?
@priyankocts, @ashishshukla1183 the dynamic data functionality is now officially releaced. You can use it instead of the event aggregator.
https://twitter.com/SharePoint/status/1060619788744097793?s=19
I had the same problem.
I use "Events" (+ polyfill for old navigator like IE11) for the moment. I will wait for 1.7 to use dynamic data.
Cheers,
@maximreynaud , 1.7 is out! You can upgrade your project (using the office 365 cli) and migrate to dynamic data.