{"action":"created","issue":{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/3216","repository_url":"https://api.github.com/repos/marionettejs/backbone.marionette","labels_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/3216/labels{/name}","comments_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/3216/comments","events_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/3216/events","html_url":"https://github.com/marionettejs/backbone.marionette/pull/3216","id":180822204,"number":3216,"title":"[WIP] filter should attach/detach and leave children alone","user":{"login":"paulfalgout","id":2028470,"avatar_url":"https://avatars.githubusercontent.com/u/2028470?v=3","gravatar_id":"","url":"https://api.github.com/users/paulfalgout","html_url":"https://github.com/paulfalgout","followers_url":"https://api.github.com/users/paulfalgout/followers","following_url":"https://api.github.com/users/paulfalgout/following{/other_user}","gists_url":"https://api.github.com/users/paulfalgout/gists{/gist_id}","starred_url":"https://api.github.com/users/paulfalgout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulfalgout/subscriptions","organizations_url":"https://api.github.com/users/paulfalgout/orgs","repos_url":"https://api.github.com/users/paulfalgout/repos","events_url":"https://api.github.com/users/paulfalgout/events{/privacy}","received_events_url":"https://api.github.com/users/paulfalgout/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/labels/discussion","name":"discussion","color":"cccccc"},{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/labels/next","name":"next","color":"009800"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-04T07:23:35Z","updated_at":"2016-10-04T12:17:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/pulls/3216","html_url":"https://github.com/marionettejs/backbone.marionette/pull/3216","diff_url":"https://github.com/marionettejs/backbone.marionette/pull/3216.diff","patch_url":"https://github.com/marionettejs/backbone.marionette/pull/3216.patch"},"body":"This is barely a WIP.. just some playing..\r\n\r\nBut while trying to wrap my head around the complexities in https://github.com/marionettejs/backbone.marionette/pull/3173 I began pondering what is making things so complex.\r\n\r\nI think Marionette could support filter functionality in a very similar way / API as it does now, but if handled very differently it could greatly reduce the code complexity.  But there are so many moving parts I want to float the idea before I go any further..\r\n\r\n**Proposal:**\r\n\r\nMarionette's filtering should not modify `children`.  Filter should merely decide which children are attached / detached.  Marionette should maintain children as a collection of views that match the backbone collection.  If a view inside the children is not filtered out, it would be rendered and attached.. if that view is ever filtered out, it would merely be detached.. if the filter changed and it could be displayed again it would simply be reattached and not re-rendered.  Views that were never attached would never be rendered.\r\n\r\nI believe this reduces the complexity greatly.  As models are added and removed from the collection, adding them to children is trivial as we don't have to worry about filtering..\r\n\r\nSo the logic would be\r\ncollection events -> update children -> sort children -> update DOM from sort -> attach/detach views as per the filter.\r\n\r\nIf a view is _removed_ from children via the bb model, then we'd destroy the childview.. otherwise we're just detaching until the collectionview is destroyed.. at that point we can clean up everything else.\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/comments/251371667","html_url":"https://github.com/marionettejs/backbone.marionette/pull/3216#issuecomment-251371667","issue_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/3216","id":251371667,"user":{"login":"scott-w","id":1969937,"avatar_url":"https://avatars.githubusercontent.com/u/1969937?v=3","gravatar_id":"","url":"https://api.github.com/users/scott-w","html_url":"https://github.com/scott-w","followers_url":"https://api.github.com/users/scott-w/followers","following_url":"https://api.github.com/users/scott-w/following{/other_user}","gists_url":"https://api.github.com/users/scott-w/gists{/gist_id}","starred_url":"https://api.github.com/users/scott-w/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scott-w/subscriptions","organizations_url":"https://api.github.com/users/scott-w/orgs","repos_url":"https://api.github.com/users/scott-w/repos","events_url":"https://api.github.com/users/scott-w/events{/privacy}","received_events_url":"https://api.github.com/users/scott-w/received_events","type":"User","site_admin":false},"created_at":"2016-10-04T12:17:40Z","updated_at":"2016-10-04T12:17:40Z","body":"Have you looked into www.scottwalton.codes/marionette.collectionhelper which I wrote to be a way of handling sorting, filtering and paging separately from Mn views?"}}
{"actor":{"display_login":"scott-w"}}