Skip to content

Commit aba656d

Browse files
committed
convert before screen load event to extension type
1 parent f7e3868 commit aba656d

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

lib/src/web/static_interop/screenset_event/before_screen_load_event.dart

+9-20
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,21 @@
1-
import 'package:js/js.dart';
2-
import 'package:js/js_util.dart';
1+
import 'dart:js_interop';
32

43
import '../../../models/screenset_event.dart';
54
import '../models/profile.dart';
65

7-
/// This typedef defines the function signature for the handler of the screenset before screen load event.
8-
///
9-
/// This function should return false to cancel the next screen load or true to continue loading the screen.
10-
/// This function can also return a [Map] with a `nextScreen` key to override the default screenset flow,
11-
/// by showing a different screen in a specific scenario.
12-
typedef BeforeScreenLoadEventHandler = Object? Function(ScreensetEvent event);
13-
14-
/// The static interop class for the before screen load event of the `Account.showScreenset` event stream.
6+
/// The extension type for the before screen load event of the `Account.showScreenset` event stream.
157
///
168
/// See: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/413a5b7170b21014bbc5a10ce4041860.html?locale=en-US#onbeforescreenload-event-data
179
@JS()
1810
@anonymous
1911
@staticInterop
20-
class BeforeScreenLoadEvent {}
21-
22-
/// This extension defines the static interop definition
23-
/// for the [BeforeScreenLoadEvent] class.
24-
extension BeforeScreenLoadEventExtension on BeforeScreenLoadEvent {
12+
extension type BeforeScreenLoadEvent(JSObject _) {
2513
/// The name of the current screen, before the screen switch.
2614
external String get currentScreen;
2715

28-
/// The site custom data fields related to the user, as known before the form submission.
29-
external Object? get data;
16+
/// The site custom data fields related to the user,
17+
/// as known before the form submission.
18+
external JSAny? get data;
3019

3120
/// The name of the event.
3221
external String get eventName;
@@ -41,7 +30,7 @@ extension BeforeScreenLoadEventExtension on BeforeScreenLoadEvent {
4130
external Profile? get profile;
4231

4332
/// The response of the previous screen's submit operation.
44-
external Object? get response;
33+
external JSAny? get response;
4534

4635
/// The source plugin that generated this event.
4736
/// The value of this field is the name of the plugin's API method,
@@ -54,11 +43,11 @@ extension BeforeScreenLoadEventExtension on BeforeScreenLoadEvent {
5443
eventName,
5544
<String, dynamic>{
5645
'currentScreen': currentScreen,
57-
'data': dartify(data),
46+
'data': data.dartify(),
5847
'form': form,
5948
'nextScreen': nextScreen,
6049
'profile': profile?.toMap(),
61-
'response': dartify(response),
50+
'response': response.dartify(),
6251
'source': source,
6352
},
6453
);

0 commit comments

Comments
 (0)