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.

multiple bindings in forEach

See original GitHub issue

在使用forEach时,如果有多个元素做forEach,如 在layer里画若干个点

layer.forEach(function(g) {
    g.on('click', function(e) {
        console.log('test')
    }).
});

预期的结果应该是layer里的每一个点都被绑定了一个点击事件,点击一下打印test。 而在编写中发现有时会出现多重绑定的时间,比如layer里有三个对象,那forEach之后点击一下其中一个元素会打印三次。 并非每次都会出现这个问题,但是出现的次数不少

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cXiaofcommented, Nov 9, 2017

我也暂时重现不了,尝试着玩没做版本管理回不去了,那就先关了吧再遇到了再说

0reactions
fuzhenncommented, Nov 9, 2017

重现了 👌 感谢发现一个新的bug, 很开心, 哈哈

Read more comments on GitHub >

github_iconTop Results From Across the Web

ios - @Binding and ForEach in SwiftUI - Stack Overflow
Indices create bugs. Swift and SwiftUI provide MULTIPLE other means for getting array members. Who gave this a green checkmark?! – ...
Read more >
ForEach Breaks Data Binding | Apple Developer Forums
Using a ForEach loop breaks my data binding to an object in an array. I can create my view using the index of...
Read more >
How to create a List or a ForEach from a binding
SwiftUI lets us create a List or ForEach directly from a binding, which then provides the content closure with individual bindings to each ......
Read more >
The "foreach" binding - Knockout.js
The foreach binding duplicates a section of markup for each entry in an array, and binds each copy of that markup to the...
Read more >
Bindable SwiftUI list elements - Swift by Sundell
Setting up two-way bindings between the elements in a collection and a series of SwiftUI views.
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