initializeBackend(backendName) {
        const registryFactoryEntry = this.registryFactory[backendName];
        if (registryFactoryEntry == null) throw new Error(`Cannot initialize backend ${backendName}, no registration found.`);
        try {
            const backend = registryFactoryEntry.factory();
            /* Test if the factory returns a promise.
            Done in a more liberal way than
            previous 'Promise.resolve(backend)===backend'
            as we needed to account for custom Promise
            implementations (e.g. Angular) */ if (backend && !(backend instanceof (0, _backend.KernelBackend)) && typeof backend.then === "function") {
                const promiseId = ++this.pendingBackendInitId;
                const success = backend.then((backendInstance)=>{
                    // Outdated promise. Another backend was set in the meantime.
                    if (promiseId < this.pendingBackendInitId) return false;
                    this.registry[backendName] = backendInstance;
                    this.pendingBackendInit = null;
                    return true;
                }).catch((err)=>{
                    // Outdated promise. Another backend was set in the meantime.
                    if (promiseId < this.pendingBackendInitId) return false;
                    this.pendingBackendInit = null;
                    _log.warn(`Initialization of backend ${backendName} failed`);
                    _log.warn(err.stack || err.message);
                    return false;
                });
                this.pendingBackendInit = success;
                return {
                    success,
                    asyncInit: true
                };
            } else {
                this.registry[backendName] = backend;
                return {
                    success: true,
                    asyncInit: false
                };
            }
        } catch (err) {
            _log.warn(`Initialization of backend ${backendName} failed`);
            _log.warn(err.stack || err.message);
            return {
                success: false,
                asyncInit: false
            };
        }
    }
Initializes a backend by looking up the backend name in the factory
registry and calling the factory method. Returns a boolean representing
whether the initialization of the backend suceeded. Throws an error if
there is no backend in the factory registry.