Git Product home page Git Product logo

Comments (13)

jazithedev avatar jazithedev commented on September 15, 2024 1

Ok, no worries. I will wait for it then 🙂. Good luck 🤞!

from collection.

drupol avatar drupol commented on September 15, 2024

Hi !

Interesting, let me check this out locally with version 6, master and I'll get back to you.

from collection.

jazithedev avatar jazithedev commented on September 15, 2024

Thank you for VERY fast response @drupol 🍻

from collection.

drupol avatar drupol commented on September 15, 2024

You're welcome.

I cannot reproduce the issue with the master branch, everything seems to be ok there.

Going to investigate the issue on version ^6...

from collection.

drupol avatar drupol commented on September 15, 2024

This is the commit who fixed the issue a69acec

from collection.

jazithedev avatar jazithedev commented on September 15, 2024

Thanks! I suppose it will be soon pushed on the next library version?

from collection.

drupol avatar drupol commented on September 15, 2024

I'm still investigating which lines fixed the issue. I need to provide a fix and release a version 6.0.4 with the fix only.

from collection.

drupol avatar drupol commented on September 15, 2024

Ok, got the reason.

That commit is actually one of the most important commit. This is mostly the reason why there will be a major version bump.

The sad news is that I'm afraid this won't be fixable in v6 :( it would require to rewrite almost every operations.

The good news is that now I need to hurry and release version 7. I took a bit of delay to finish it. There's still #256 to finish and we're good to go.

from collection.

jazithedev avatar jazithedev commented on September 15, 2024

I see. It is ok. I managed to make a workaround on my side by casting the collection to an array (unfortunately), and getting the value by a key at that point. Keep up the good work, and can't wait for v7 🙂.

from collection.

jazithedev avatar jazithedev commented on September 15, 2024

And, of course, thank you for your help and fast reaction once again 👍️.

from collection.

drupol avatar drupol commented on September 15, 2024

I just added your tests in the codebase to make sure it doesn't happen again in v7 :)

Thanks for reporting it !

from collection.

rela589n avatar rela589n commented on September 15, 2024

Hi there!

Does the cache really work in this case?

$test = Collection::fromCallable(static function () {
    var_dump('data call');

    yield 100 => 'a';
})->cache();

$result1 = $test->all();
$result2 = $test->all();

var_dump($result1, $result2);

This code outputs following result:

string(9) "data call"
string(9) "data call"
array(1) {
  [0]=>
  string(1) "a"
}
array(1) {
  [0]=>
  string(1) "a"
}

It doesn't seem to work correctly, since it calls for data every time 🤔

from collection.

drupol avatar drupol commented on September 15, 2024

This is weird indeed, but this is an expected behavior due to the immutable nature of the Collection.

To make it work "as expected", add the squash operation, use just use it without cache().

However, this issue gaves me an idea to add a new operation memorize that would do that... I just did in 5 minutes, I might probably finalize it next week (see #316).

from collection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.