@abaplint/runtime 2.13.54 → 2.13.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,10 +3,12 @@ export type ABAPEventReference = {
3
3
  EVENT_NAME: string;
4
4
  EVENT_CLASS: string;
5
5
  };
6
- type HandlerMethod = (parameters?: any) => Promise<void>;
6
+ export type HandlerMethod = {
7
+ method: (parameters?: any) => Promise<void>;
8
+ receiver: object;
9
+ };
7
10
  export declare class ABAPEventing {
8
11
  private readonly registrations;
9
12
  setHandler(event: ABAPEventReference, methods: HandlerMethod[], forObject: ABAPObject | "ALL", activation: boolean): any;
10
13
  raiseEvent(event: ABAPEventReference, me: ABAPObject, parameters: object): Promise<void>;
11
14
  }
12
- export {};
@@ -26,12 +26,13 @@ class ABAPEventing {
26
26
  if (methods.length > 1) {
27
27
  throw new Error("ABAPEventing.setHandler: deactivation of multiple methods not supported, todo");
28
28
  }
29
- // todo: comparing the functions via toString might give the wrong result
30
29
  const index = handlers.findIndex(handler => {
31
30
  const sameObject = handler.forObject === "ALL"
32
31
  ? target === "ALL"
33
32
  : target !== "ALL" && handler.forObject.deref() === target;
34
- return sameObject && handler.handlers[0].toString() === methods[0].toString();
33
+ const sameMethod = handler.handlers[0].method === methods[0].method
34
+ && handler.handlers[0].receiver === methods[0].receiver;
35
+ return sameObject && sameMethod;
35
36
  });
36
37
  if (index !== -1) {
37
38
  handlers.splice(index, 1);
@@ -47,12 +48,12 @@ class ABAPEventing {
47
48
  for (const handler of handlers) {
48
49
  if (handler.forObject === "ALL") {
49
50
  for (const method of handler.handlers) {
50
- await method(parameters);
51
+ await method.method.call(method.receiver, parameters);
51
52
  }
52
53
  }
53
54
  else if (handler.forObject.deref() === me.get()) {
54
55
  for (const method of handler.handlers) {
55
- await method(parameters);
56
+ await method.method.call(method.receiver, parameters);
56
57
  }
57
58
  }
58
59
  }
@@ -1,4 +1,4 @@
1
- import { ABAPEventReference } from "../abap_eventing";
1
+ import { ABAPEventReference, HandlerMethod } from "../abap_eventing";
2
2
  import { ABAPObject, FieldSymbol } from "../types";
3
3
  import { ICharacter } from "../types/_character";
4
- export declare function setHandler(eventReference: ABAPEventReference, methods: any[], forObject: ABAPObject | FieldSymbol, activation?: ICharacter): void;
4
+ export declare function setHandler(eventReference: ABAPEventReference, methods: HandlerMethod[], forObject: ABAPObject | FieldSymbol, activation?: ICharacter): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.13.54",
3
+ "version": "2.13.55",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",