0

For my store, I have something along the lines of:

var GraphStore = Reflux.createStore({
    listenables: [GraphActions],
    updateGraphedMetrics: function(graphs) {
        ...
        this.trigger(graphs);
    },
    getInitialState: function() {
        this.graphedMetrics = [];
        return this.graphs;
  }
});

I am listening using:

var Dashboard = React.createClass({
  mixins: [Reflux.connect(GraphStore,"graphs")],
  render: function() {
  ...
  }
});

This works great. However, what if I wanted to listen to changes at a specific index in graphs (the stateKey), rather than the entire array? Is that possible with the current structure? If not, what might be the best way to go about it?

Matthew Herbst
  • 29,477
  • 23
  • 85
  • 128
  • Actually, I think I might be able to do it with: https://github.com/spoike/refluxjs#using-refluxconnectfilter Though that still seems a bit inefficient since the filter **will check every element in the array**. – Matthew Herbst Mar 26 '15 at 03:15
  • 1
    Could you add a function to the store that returns the last array elements updated? Is this optimization worth it though? – WiredPrairie Mar 26 '15 at 10:40
  • @WiredPrairie That's not a bad idea though if I thought the store was really going to have a massive first-level list. I'll give it some thought, thanks! – Matthew Herbst Mar 27 '15 at 00:56

0 Answers0