How To
Documentation
    Learn More

      ResponseService

      Description

      Twigkit service for setting and getting responses.

      Methods

      • clearResponses()

        Removes all responses from the factory.

        Example

        ResponseService.clearResponses();

      • createResponseFromResults(results)

        Creates a response object from the set of results you provide

        Parameters
        ParamTypeDetails
        resultsarray

        The list of results to add to this response.

        Returns
        Object

        Returns a newly created response object with the results provided.

        Example

        ResponseService.createResponseFromResults(results);

      • getResponse(name, keys)

        Gets response from the factory.

        Parameters
        ParamTypeDetails
        namestring

        The name of the response to retrieve

        keys
        (optional)
        string

        A comma separated list of keys you would like returned. If null whole response will be returned.

        Returns
        Object

        Returns the response object from the factory, if it doesn't exist it will return null

        Example

        ResponseService.getResponse(name);

      • setResponse(name, value)

        Adds response to response factory for retrieval using the getResponse method. Broadcasts an event of 'responsename_updated' with the new response value.

        Parameters
        ParamTypeDetails
        namestring

        The name of the response

        valueObject

        The response object to add to the factory.

        Example

        ResponseService.setResponse(name, value);