Exemplo n.º 1
0
        private void HandleComponentRender(RenderEvent renderEvent)
        {
            if (renderEvent.DidComponentRender(ComponentId))
            {
                _logger.LogDebug(new EventId(1, nameof(HandleComponentRender)), $"Received a new render where component {ComponentId} did render.");

                RenderCount++;

                // First notify derived types, e.g. queried AngleSharp collections or elements
                // that the markup has changed and they should rerun their queries.
                HandleChangesToMarkup(renderEvent);

                // Then it is safe to tell anybody waiting on updates or changes to the rendered fragment
                // that they can redo their assertions or continue processing.
                OnAfterRender?.Invoke();
            }
        }
Exemplo n.º 2
0
        private void HandleChangesToMarkup(RenderEvent renderEvent)
        {
            if (renderEvent.HasMarkupChanges(ComponentId))
            {
                _logger.LogDebug(new EventId(1, nameof(HandleChangesToMarkup)), $"Received a new render where the markup of component {ComponentId} changed.");

                // The lock ensures that latest nodes is always based on the latest rendered markup.
                lock (_lock)
                {
                    _latestRenderNodes = null;
                    _markup            = RetrieveLatestMarkupFromRenderer();
                }

                OnMarkupUpdated?.Invoke();
            }
            else if (renderEvent.DidComponentDispose(ComponentId))
            {
                _logger.LogDebug(new EventId(1, nameof(HandleChangesToMarkup)), $"Received a new render where the component {ComponentId} was disposed.");
                Renderer.RemoveRenderEventHandler(this);
            }
        }
Exemplo n.º 3
0
 Task IRenderEventHandler.Handle(RenderEvent renderEvent)
 {
     HandleComponentRender(renderEvent);
     return(Task.CompletedTask);
 }
Exemplo n.º 4
0
 public Task Handle(RenderEvent renderEvent)
 {
     ReceivedEvents.Add(renderEvent);
     return(_handleTask.Task);
 }