Instantiating SCWebCore

Creating a SCWebCore instance is easy. SCWebCore can be instantiated by providing a javascript object conforming to the Configuration class model. If the configuration is not provided, SCWebCore will create a new configuration with default values.

Creating and configuring a SCWebCore instance with your Symptom Checker API Access credentials looks like this.

var config = {
    public_key: 'key'
    private_key: 'your-private-key'
}
var scWebCore = SCWebCore(config);

In addition to your public and private key pair, you might want to specify the api environment, api version or language code for the symptom checker environment that you would like to connect to. The default values for each of these properties should reference the current stable Symptom Checker API version.

Once you have your SCWebCore instance, you can use it to:

Reading through the rest of the tutorials is the best way to learn how to use the features of the SCWebCore library.

Example Implementation

In the example implementation we let angular instantiate SCWebCore for us and make a reference to single instance available throughout our angular module. We do this by registering SCWebCore as a service in our angular application. We also provide our configuration object, so that angular can initialize the library with our configuration options. At the top of app/config.js you will find:

ApplicationConfiguration.registerModule('core', []);

angular.module('core').value('scWebCoreConfiguration', {scWebCoreConfiguration});

angular.module('core').service('SCWebCore', ['scWebCoreConfiguration', SCWebCore]);

In this code block, scWebCoreConfiguration represents our configuration object. In the project's concat-app build phase our build time configuration options (found in config/) are declared as var scWebCoreConfiguration.

First we register our 'core' module as an angular module. Then we declare our application configuration as a value within our angular application. After that, we register an angular service named SCWebCore with our module. We provide the SCWebCore module as our service and inject the configuration into it by identifying the angular value that we have registered our configuration under.

Now that SCWebCore is registered as a service in our angular module, we can refer to a single instance of the module from anywhere in our application.

See how we use it in the following guides.