Beispiel #1
0
        /// <summary>
        /// Associates the <see cref="IComponent"/> with the <see cref="RemoteRenderer"/>,
        /// causing it to be displayed in the specified DOM element.
        /// </summary>
        /// <param name="componentType">The type of the component.</param>
        /// <param name="domElementSelector">A CSS selector that uniquely identifies a DOM element.</param>
        public Task AddComponentAsync(Type componentType, string domElementSelector)
        {
            var component   = InstantiateComponent(componentType);
            var componentId = AssignRootComponentId(component);

            var attachComponentTask = _client.SendAsync("JS.AttachComponent", componentId, domElementSelector);

            CaptureAsyncExceptions(attachComponentTask);

            return(RenderRootComponentAsync(componentId));
        }
Beispiel #2
0
        protected override void BeginInvokeJS(long asyncHandle, string identifier, string argsJson)
        {
            if (!_clientProxy.Connected)
            {
                throw new InvalidOperationException("JavaScript interop calls cannot be issued at this time. This is because the component is being " +
                                                    "prerendered and the page has not yet loaded in the browser or because the circuit is currently disconnected. " +
                                                    "Components must wrap any JavaScript interop calls in conditional logic to ensure those interop calls are not " +
                                                    "attempted during prerendering or while the client is disconnected.");
            }

            _clientProxy.SendAsync("JS.BeginInvokeJS", asyncHandle, identifier, argsJson);
        }
Beispiel #3
0
        protected override void AttachRootComponentToBrowser(int componentId, string domElementSelector)
        {
            var attachComponentTask = _client.SendAsync("JS.AttachComponent", componentId, domElementSelector);

            _ = CaptureAsyncExceptions(attachComponentTask);
        }