
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
ember-large-list
Advanced tools
Alternative and simpler approach to ember-collections for rendering large arrays to dom
Want to render a large list of items in paginated groups, but Ember's DOM teardowns and setups are reducing performance, and "canonical" smoke-and-mirrors patterns (e.g. ember-collection) is causing memory-leak crashes?
This addon is for you.
ember install ember-large-list
It's also up to you to provide the compute
template helper.
This repo just sorta assumes you have it. (see how to implement)
<ul>
{{#large-list items=data startIndex=0 perPage=5 as |item globalIndex localIndex|}}
{{my-row-presentation data=item}}
{{!-- globalIndex goes from 0 to (data.length - 1) --}}
{{!-- localIndex goes from 0 to (perPage - 1) --}}
{{/large-list}}
</ul>
note: you can also use
offset
andlimit
instead ofstartIndex
andperPage
; they are aliased
Very simple, instead of using each
, we use n.times
. Consider the following pseudo-code in ruby:
paged_list = items.slice(start_index).take(per_page)
per_page.times do |i|
yield paged_list[i]
end
We can translate this idea over to hbs and javascript like so:
large-list/component.js
Component.extend({
startIndex: 0,
perPage: 5,
items: [
{ name: 'God of War', icon: 'images/god-of-war.png' },
// ...
]
});
large-list/template.hbs
{{#let (take items startIndex perPage) as |smallArray|}}
{{#n-times perPage do |index|}}
{{my-row-presentation data=(get smallArray index)}}
{{/n-times}}
{{/let}}
And that's it! Instead of depending on each
to iterate through out array, we use generic helpers let
, take
, and n-times
and suddenly, we guarantee ourselves the following:
perPage=5
elements are ever rendered to domthis.element
) happensregisterChild
anti-patternNot really, given how simple the actual solution to performant rendering is, all you need is the take
helper and the n-times
component
However, this addon does provide the helpful following
git clone <repository-url>
cd ember-large-list
npm install
npm run lint:hbs
npm run lint:js
npm run lint:js -- --fix
ember test
– Runs the test suite on the current Ember versionember test --server
– Runs the test suite in "watch mode"ember try:each
– Runs the test suite against multiple Ember versionsember serve
For more information on using ember-cli, visit https://ember-cli.com/.
This project is licensed under the MIT License.
FAQs
Alternative and simpler approach to ember-collections for rendering large arrays to dom
We found that ember-large-list demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.