From acee5d2b929a9b9034c0932564450727021a0dfa Mon Sep 17 00:00:00 2001
From: Philipp Rudiger
Date: Fri, 14 Oct 2016 17:56:40 +0100
Subject: [PATCH] Added stream activate and deactivate methods
---
holoviews/streams.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/holoviews/streams.py b/holoviews/streams.py
index 5a6f0c9cce..c6bd3dd11e 100644
--- a/holoviews/streams.py
+++ b/holoviews/streams.py
@@ -106,6 +106,9 @@ def trigger(cls, streams):
for subscriber in subscribers:
subscriber(**dict(union))
+ for stream in streams:
+ stream.deactivate()
+
def __init__(self, preprocessors=[], source=None, subscribers=[], **params):
"""
@@ -125,6 +128,21 @@ def __init__(self, preprocessors=[], source=None, subscribers=[], **params):
if source:
self.registry[id(source)].append(self)
+
+ def activate(self):
+ """
+ Allows defining an action before the stream is updated.
+ """
+ pass
+
+
+ def deactivate(self):
+ """
+ Allows defining an action after the stream has been triggered.
+ """
+ pass
+
+
@property
def source(self):
return self._source
@@ -153,6 +171,7 @@ def update(self, trigger=True, **kwargs):
If trigger is enabled, the trigger classmethod is invoked on
this particular Stream instance.
"""
+ self.activate()
params = self.params().values()
constants = [p.constant for p in params]
for param in params: