Skip to main content

Use Subjects

The following sections provides information to use a subject in an application. In the context of QuotingHealth application, a subject called DisableQuote is created to manage the state of whether a quote can be disabled or enabled, and it allows other parts of an application to observe and control this state.

Create a Subject​

To create the DisableQuote subject with type as boolean, follow the steps given in Create Subjects.

DisableQuote Subject

Create Subscription​

Follow the below steps to create a subscription.

  1. Refer to Create Subscription and create a subscription in an interface to use this subject with the following properties.
    • Name: QuoteDisable
    • Service: QuoteEdit
    • Subject: DisableQuote
  2. Configure the logic in the subscription using the constructs.
    1. Use the If construct to check the status of the subject.
    2. For true condition of the flag, use the log construct to write a message in the console. The expression used is "Sys.ConsoleLog("Exposures form disable:", data)".
    3. Use the Disable FromGroups construct to disable the entire form. Configure it as follows:
      • Form Selection: Whole Form.
    4. Make the flow to stop after executing the desired condition.

Subscription QuoteDisable

Emitter​

Follow the below steps to configure emitter:

  1. The Emitter construct is used to OnInit event of the quoting master layout exposures is to emit the value to any new subscriber when they subscribe.
  2. The expression used here is this.BasicQuoteDetails.QuoteDetails.Status == AppConstants.QUOTE_ACCEPTED || this.BasicQuoteDetails.QuoteDetails.Status==AppConstants.QUOTE_REJECTED ||(this.BasicQuoteDetails.QuoteDetails.Status==AppConstants.QUOTE_REFERRED && Sys.ArrayContains(this.securityContext.Roles(), AppConstants.AGENT))

Emitter

Subscribe​

Follow the below steps to subscribe to this subscription.

  1. The OnInit event of the exposures subscribes to this subject to disable form groups based on the value of the subject provided by the emitter. The subscribe construct is configured as follows:
    • Service: QuoteEdit
    • Subject: DisableQuote
    • Subscription: QuoteDisable

Subscriber