Skip to content

Commit

Permalink
Fixed subscription settings not updating on graph widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Dec 17, 2023
1 parent c598dcd commit 26caaf1
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions lib/widgets/nt_widgets/single_topic/graph.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:async';

import 'package:elastic_dashboard/services/nt_connection.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

Expand Down Expand Up @@ -221,6 +220,26 @@ class _GraphWidgetGraphState extends State<_GraphWidgetGraph> {

widget.currentData = graphData;

initializeListener();
}

@override
void dispose() {
seriesController = null;
subscriptionListener?.cancel();

super.dispose();
}

@override
void didUpdateWidget(_GraphWidgetGraph oldWidget) {
subscriptionListener?.cancel();
initializeListener();

super.didUpdateWidget(oldWidget);
}

void initializeListener() {
subscriptionListener =
widget.subscription?.timestampedStream(yieldAll: true).listen((data) {
if (data.key != null) {
Expand Down Expand Up @@ -272,14 +291,6 @@ class _GraphWidgetGraphState extends State<_GraphWidgetGraph> {
});
}

@override
void dispose() {
seriesController = null;
subscriptionListener?.cancel();

super.dispose();
}

List<FastLineSeries<_GraphPoint, num>> getChartData() {
return <FastLineSeries<_GraphPoint, num>>[
FastLineSeries<_GraphPoint, num>(
Expand Down

0 comments on commit 26caaf1

Please sign in to comment.