{"id":21125337,"url":"https://github.com/ripjar/backbone.assign","last_synced_at":"2025-07-04T16:34:30.423Z","repository":{"id":77174182,"uuid":"50453478","full_name":"ripjar/backbone.assign","owner":"ripjar","description":"Memory conscious Backbone views.","archived":false,"fork":false,"pushed_at":"2016-09-22T14:55:11.000Z","size":606,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-14T11:41:24.283Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ripjar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-26T19:31:12.000Z","updated_at":"2016-09-26T11:24:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"e333429f-9188-445f-9360-2fb20bd8c87c","html_url":"https://github.com/ripjar/backbone.assign","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ripjar/backbone.assign","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripjar%2Fbackbone.assign","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripjar%2Fbackbone.assign/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripjar%2Fbackbone.assign/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripjar%2Fbackbone.assign/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ripjar","download_url":"https://codeload.github.com/ripjar/backbone.assign/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripjar%2Fbackbone.assign/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263577257,"owners_count":23483130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T04:24:05.425Z","updated_at":"2025-07-04T16:34:30.402Z","avatar_url":"https://github.com/ripjar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# backbone.assign\n\nA micro library for creating memory conciencious Backbone views.\n\n# Reasoning \n\nIn long-lived, single page web-apps, the importance of maintaining a zero memory footprint is high. Although performing various cleanup operations,vanilla Backbone does not allow for views to easily manage the state of their sub-views. This makes it difficult to ensure that when views are destroyed they efficiently and completely cleanup all event handlers and elements they have created and delegated.\n\n# Installation \n\n    npm install backbone.assign\n\n# Usage\n\nBackbone.assign is provided as an ES6 module;\n\n    import ParentView from \"backbone.assign\";\n\nUsing Backbone.assign, sub-views are assigned to a child element, and then rendered implicitly. This allows backbone.assign and the parent view to manage the state of all of it's sub-views. An example view assignment may be as follows;\n\n    const PageView = ParentView.extend({\n        initialize(options) {\n            // create a view\n            this.listView = new ListView();\n        },\n        render() {\n            // render and append the view\n            // to the .list element\n            this.assign({\n                '.list': this.listView\n            });\n        }\n    });\n\n# Assumptions\n\nIn order for backbone.assign to work effectively without intervention, two asumptionns are made;\n\n1. **All events will be delegated from the root element of the view.**\n   This can be achieved by using the `events` object exclusively, or by delegating events from `this.el`.\n2. **The `render` function will not alter the view's root element.**   \n\n# Events\n\n| Event Name        | Description   |\n| ------------------|---------------| \n| `onBeforeRender`  | called immediately before the view is rendered |\n| `onRender`        | called immediately after the view is rendered  |\n| `onBeforeClose`   | called immediately before the view is closed   |\n| `onClose`         | called immediately after the view is closed    |\n\n# Additional cleanup\n\nTo perform any additional cleanup of memory an `onClose` method is exposed. The `onClose` function will be called after the `onBeforeClose` event, but before memory cleanup. This \n\n### Preventing final cleanup\n\nReturning `false` from the `onClose` function will rekindle the view, preventing cleanup from being finalized. \n\n# Drawbacks\n\n# License","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fripjar%2Fbackbone.assign","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fripjar%2Fbackbone.assign","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fripjar%2Fbackbone.assign/lists"}