Add filter rule to AppListener More...
Import Statement: | import |
Filter component listens for the parent's dispatched signal, if a dispatched signal match with its type, it will emit its own "dispatched" signal. Otherwise, it will simply ignore the signal.
This component provides an alternative way to filter incoming message which is suitable for making Store component.
Example:
pragma Singleton import QtQuick 2.0 import QuickFlux 1.0 import "../actions" AppListener { id: store property ListModel model: ListModel { } Filter { type: ActionTypes.addTask onDispatched: { model.append({task: message.task}); } } }
It is not suggested to use nested AppListener in a Store component. Because nested AppListener do not share the same AppListener::listenerId, it will be difficult to control the order of message reception between store component.
In contrast, Filter share the same listenerId with its parent, and therefore it is a solution for above problem.
These types determine the filtering rule for incoming message. Only type matched will emit the "dispatched" signal.
AppListener { Filter { type: "action1" onDispatched: { // handle the action } } }
See also Filter::types.
These types determine the filtering rule for incoming message. Only type matched will emit the "dispatched" signal.
AppListener { Filter { types: ["action1", "action2"] onDispatched: { // handle the action } } }
See also Filter::type.
It is a proxy of parent's dispatched signal. If the parent emits a signal matched with the Filter::type / Filter::types property, it will emit this signal