Skip to main content

CausalClientProtocol

EXTENSION

CausalClientProtocol

public extension CausalClientProtocol

Methods

requestFeatures(_:)

func requestFeatures(_ features: [any FeatureProtocol]) async -> Error?

Requests a set of features to be updated from the impression server and updates them in-place.

If your project is using SwiftUI we encourage the usage of the compiler generated view models in addition to the requestCacheFill() method to request features from the impression service. However, If you wish to use the CausalClient directly then this method is recommended.

  • Note:

    • An impression id will be automatically generated and used when calling this method.
    • In the event of an error the input features instance contains default values and can be used to render the feature to the screen.
  • Parameters:

    • features: The features to request. Upon successful completion the features instances will be updated in-place from the impression service data.
    • impressionId: The impression id that matches the specific view of the requested features.
  • Returns: A CausalError or an iOS SDK Error, if one occurred.

Parameters

NameDescription
featuresThe features to request. Upon successful completion the features instances will be updated in-place from the impression service data.
impressionIdThe impression id that matches the specific view of the requested features.

requestFeature(_:)

func requestFeature(_ feature: any FeatureProtocol) async -> Error?

Requests a single feature to be updated from the impression server. The passed in feature will be updated in-place with the results from the impression service.

  • Note:

    • An impression id will be automatically generated and used when calling this method.
    • In the event of an error the input feature instance contains default values and can be used to render the feature to the screen.
  • Parameters:

    • feature: The feature to request. Upon successful completion the feature instance will be updated in-place from the impression service data.
  • Returns: The updated feature from the server, or the default feature if there was an error.

  • Throws: A CausalError or an iOS SDK Error.

Parameters

NameDescription
featureThe feature to request. Upon successful completion the feature instance will be updated in-place from the impression service data.