@stigg/js-client-sdk 0.41.0 → 0.42.0

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.
package/dist/client.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { BooleanEntitlement, Coupon, Customer, Entitlement, GetBooleanEntitlement, GetMeteredEntitlement, GetNumericEntitlement, GetPaywall, MeteredEntitlement, NumericEntitlement, Plan, Subscription, WaitForCheckoutCompleted } from './models';
2
2
  import { ClientConfiguration } from './configuration';
3
+ import { EventNames, Events } from './services/eventEmitter';
3
4
  export interface StiggClient {
4
5
  isCustomerLoaded: boolean;
5
6
  getBooleanEntitlement: (params: GetBooleanEntitlement) => BooleanEntitlement;
@@ -11,6 +12,8 @@ export interface StiggClient {
11
12
  getEntitlements: () => Promise<Entitlement[]>;
12
13
  refresh: () => Promise<void>;
13
14
  waitForCheckoutCompleted(params?: WaitForCheckoutCompleted): Promise<Subscription | null>;
15
+ addListener: <K extends EventNames>(eventName: K, callback: Events[K]) => void;
16
+ removeListener: <K extends EventNames>(eventName: K, callback: Events[K]) => void;
14
17
  }
15
18
  export declare class Stigg implements StiggClient {
16
19
  private readonly apiGateway;
@@ -30,6 +33,18 @@ export declare class Stigg implements StiggClient {
30
33
  static initialize(configuration: ClientConfiguration): Promise<StiggClient | null>;
31
34
  private static initializeSdk;
32
35
  get isCustomerLoaded(): boolean;
36
+ /**
37
+ * Add a listener to handle updates of entitlements changes
38
+ * @param eventName
39
+ * @param listener
40
+ */
41
+ addListener<K extends EventNames>(eventName: K, listener: Events[K]): void;
42
+ /**
43
+ * Remove a listener to stop handle updates of entitlements changes
44
+ * @param eventName
45
+ * @param listener
46
+ */
47
+ removeListener<K extends EventNames>(eventName: K, listener: Events[K]): void;
33
48
  /**
34
49
  * Set the customer ID, usually after the customer signs in or restores a session
35
50
  */