@@ -22,8 +22,9 @@ class SplitioWeb extends SplitioPlatform {
2222
2323 late JS_IBrowserSDK _factory;
2424 String ? _trafficType;
25+ // Broadcast to allow users to subscribe multiple listeners
2526 final StreamController <Impression > _impressionsStreamController =
26- StreamController <Impression >();
27+ StreamController <Impression >. broadcast ();
2728
2829 final Map <String , JS_IBrowserClient > _clients = {};
2930
@@ -86,7 +87,7 @@ class SplitioWeb extends SplitioPlatform {
8687 // If not, loads it by injecting a script tag.
8788 static Future <void > _loadSplitSdk () async {
8889 if (window.splitio != null ) {
89- return ; // Already loaded
90+ return ; // Already loaded. JS SDK should not be manually loaded because `splitio.SplitFactory` is not available.
9091 }
9192
9293 // Create and inject script tag
@@ -104,7 +105,7 @@ class SplitioWeb extends SplitioPlatform {
104105
105106 script.onerror = (Event event) {
106107 completer.completeError (
107- Exception ('Failed to load Split SDK, with error: $event ' ));
108+ Exception ('Failed to load Split Browser SDK, with error: $event ' ));
108109 }.toJS;
109110
110111 document.head! .appendChild (script);
@@ -166,7 +167,7 @@ class SplitioWeb extends SplitioPlatform {
166167 urls.events =
167168 (configuration.configurationMap['eventsEndpoint' ] as String ).toJS;
168169
169- // Convert urls for consistency between JS SDK and Android/iOS SDK
170+ // Convert urls for consistency between Browser SDK and Android/iOS SDK
170171 if (configuration.configurationMap.containsKey ('authServiceEndpoint' )) {
171172 final auth =
172173 configuration.configurationMap['authServiceEndpoint' ] as String ;
@@ -299,7 +300,7 @@ class SplitioWeb extends SplitioPlatform {
299300 config.storage = window.splitio! .InLocalStorage
300301 ? .callAsFunction (null , storageOptions); // Browser SDK
301302 } else {
302- config.storage = storageOptions; // JS SDK
303+ config.storage = storageOptions; // JS or slim Browser SDK
303304 }
304305
305306 if (configuration.configurationMap['impressionListener' ] is bool ) {
@@ -437,7 +438,6 @@ class SplitioWeb extends SplitioPlatform {
437438 Map <String , dynamic > attributes = const {},
438439 EvaluationOptions evaluationOptions = const EvaluationOptions .empty (),
439440 }) async {
440- await this ._initFuture;
441441 final client = await _getClient (
442442 matchingKey: matchingKey,
443443 bucketingKey: bucketingKey,
@@ -747,7 +747,7 @@ class SplitioWeb extends SplitioPlatform {
747747 // the `onXXX` method implementations always return a Future or Stream that waits for the client to be initialized.
748748
749749 @override
750- Future <void >? onReady (
750+ Future <void > onReady (
751751 {required String matchingKey, required String ? bucketingKey}) async {
752752 final client = await _getClient (
753753 matchingKey: matchingKey,
@@ -770,7 +770,7 @@ class SplitioWeb extends SplitioPlatform {
770770 }
771771
772772 @override
773- Future <void >? onReadyFromCache (
773+ Future <void > onReadyFromCache (
774774 {required String matchingKey, required String ? bucketingKey}) async {
775775 final client = await _getClient (
776776 matchingKey: matchingKey,
@@ -793,7 +793,7 @@ class SplitioWeb extends SplitioPlatform {
793793 }
794794
795795 @override
796- Future <void >? onTimeout (
796+ Future <void > onTimeout (
797797 {required String matchingKey, required String ? bucketingKey}) async {
798798 final client = await _getClient (
799799 matchingKey: matchingKey,
@@ -816,7 +816,7 @@ class SplitioWeb extends SplitioPlatform {
816816 }
817817
818818 @override
819- Stream <void >? onUpdated (
819+ Stream <void > onUpdated (
820820 {required String matchingKey, required String ? bucketingKey}) {
821821 // To ensure the public `onUpdated` callback and `whenUpdated` method work correctly,
822822 // this method always return a stream, and the StreamController callbacks
@@ -843,6 +843,7 @@ class SplitioWeb extends SplitioPlatform {
843843 client.off (client.Event .SDK_UPDATE , jsCallback);
844844 };
845845
846+ // No broadcast to support pause and resume of individual subscriptions
846847 controller = StreamController <void >(
847848 onListen: registerJsCallback,
848849 onPause: deregisterJsCallback,
0 commit comments