Skip to contents

This class is a factory that provides concrete implementations of the Backend abstract class.

Methods


Method get()

Obtain a concrete implementation of the abstract Backend class of the specified type.

Usage

BackendFactory$get(type)

Arguments

type

A character string specifying the type of the Backend to instantiate. Possible values are "sync" and "async". See the Details section for more information.

Details

When type = "sync" a SyncBackend instance is created and returned. When type = "async" an AsyncBackend instance is provided instead.

Returns

A concrete implementation of the class Backend. It throws an error if the requested backend type is not supported.


Method clone()

The objects of this class are cloneable with this method.

Usage

BackendFactory$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Create a backend factory.
backend_factory <- BackendFactory$new()

# Get a synchronous backend instance.
backend <- backend_factory$get("sync")

# Check the class of the backend instance.
class(backend)
#> [1] "SyncBackend"    "Backend"        "BackendService" "R6"            

# Get an asynchronous backend instance.
backend <- backend_factory$get("async")

# Check the class of the backend instance.
class(backend)
#> [1] "AsyncBackend"   "Backend"        "BackendService" "R6"