question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Monkeys don't emit update events?

See original GitHub issue

I’m using monkeys to join a bunch of separate paths into an array with all of my data. My dependencies look like this:

A(cursor)              B(cursor)    C(cursor)
          \            /            /
            D(monkey)              /          
                      \          /
                        E(monkey)

When any of A, B, or C update, the appropriate monkeys are updated. However, the monkeys themselves do not appear to emit update events, which means that I don’t get the updated monkey values unless I periodically re-check them.

I could watch the cursors for updates and re-evaluate the monkeys, but then I have to declare the monkeys’ dependencies everywhere it’s used. #358 says that monkeys aren’t cursors – am I experiencing the intended monkey behavior? What is the suggested way to get an update event from a monkey?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
Nimelriancommented, Jan 26, 2017

Hello! Is there any update on this? I tried fixing this issue myself last week, but ultimately failed, because I’m not very familiar with the inner workings of Baobab.

I have written the following test case which you can drop into the monkey suite:

describe('Issue #448 - Monkeys don\'t emit update events?', function () {
  it('update events emitted by a monkey should also reach the parents of the monkey.', function (done) {
    const tree = new Baobab({
      value: 5,
      monkeys: {
        valueSquared: monkey(['value'], value => value * value)
      }
    }, {
      lazyMonkeys: false
    });

    const newValue = 10;
	
    const parentCursor = tree.select('monkeys');
    parentCursor.on('update', () => {
      assert.strictEqual(tree.get(['monkeys', 'valueSquared']), newValue * newValue);
      done();
    });

    tree.set(['value'], newValue);
  });
});
1reaction
Yomguitherealcommented, Feb 26, 2018

Merged the PR and released 2.5.1 on npm. Thanks @roark.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Monkey Patching FlexSprite to list all event listeners on any ...
The good news: you can get a list of every event listener that is currently added to any component (at least anything that...
Read more >
Monkey Patching A Touched/Dirty/Pristine Event Listener In ...
To my surprise, there is currently no event that is emitted when a control is touched – or when it's status of pristine/dirty...
Read more >
CONFIRMED Monkey Fairground 2021 Update! Roblox Adopt ...
CONFIRMED Monkey Fairground 2021 Update ! Roblox Adopt Me New Monkey Update Release Date!? Buy my new PLUSHIE here: ...
Read more >
Delegation: EventEmitter or Observable in Angular
When the user clicks on a nav-item , I would like to call a function which then emits an event which should in...
Read more >
Async event subscriber not updating UI after async call #7381
When the changed event is raised by the thing service, variable a is correctly displayed as 1 , but b and c do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found