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.

Passing the item position to `transformData`?

See original GitHub issue

For the latest integration I did, I had to apply a specific markup to the 4 first displayed hits. In my case it was not applying lazyloading of images to those elements.

So I needed to know, from inside the transformData method, the current position of the item in the returned set.

There is no easy way to do that at the moment, so I resorted to a hack involving setting a global counter (reseted on every on('render')), and increasing it on each call to my hits.transformData. It worked, but was far from optimal (code is separated in several parts, I have no clear guarantee that the transformData are actually executed in order), etc).

So I’m wondering if we shouldn’t change the transformData signature to transformData(item, position) instead of just transformData(item).

WDYT?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
vvocommented, Jun 6, 2016

Now that I know that I can pass functions to templates, I no longer need transformData…

True 😃

0reactions
pixelasticcommented, Jun 3, 2016

I’m now wondering if transformData(data, position) is the right approach. If I define my own template, I won’t have access to this position variable…

Maybe extending the data passed to templates.item and transformData.item with a __position key instead?

Now that I know that I can pass functions to templates, I no longer need transformData

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to transform data table columns, indexed by position, by ...
2: In `[.data.table`(data, , `:=`(c(4, 5), c(as.numeric(as.character(4)), : Supplied 2 items to be assigned to 7 items of column 'Sparks (D)' ( ...
Read more >
Transform data streams - Android Developers
Once you have access to the PagingData object, you can perform a map() operation on each individual item in the paged list within...
Read more >
Transform data | Grafana documentation
Use this transformation to combine the results from multiple queries (combining on a passed join field or the first time column) into one...
Read more >
Split columns by positions - Power Query | Microsoft Learn
An article on how to Split columns by positions into new columns or rows using Power Query.
Read more >
Excel Power Query Tutorial 2023: Get and Transform Data
Product number begins with “SF” → Sunflower. Here's how you can add the Category column: Open the Power Query Editor and select the...
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