Coder Social home page Coder Social logo

More complex example? about svelte-meteor-data HOT 4 CLOSED

rdb avatar rdb commented on June 14, 2024
More complex example?

from svelte-meteor-data.

Comments (4)

rdb avatar rdb commented on June 14, 2024

Hi, sorry to not have noticed this issue earlier. Before I look closer at your use case, I have just a question, do you have the immutable flag set in svelte:options?

from svelte-meteor-data.

skandragon avatar skandragon commented on June 14, 2024

I do not have that flag set. With Meteor, I'm not even sure how to set it.

That said, I seem to have solved my problems. Mostly. Kinda. :)

The work-around / solution is to make sure that I always refer to $planet in some way. For example,

function foo() {
  return planet.name
}

If I call this function as {foo()} it will return what feels like a random name for a random planet. If I rewrite this to pass in the $planet it works properly.

from svelte-meteor-data.

rdb avatar rdb commented on June 14, 2024

I think if you were to use destructuring syntax or accessed it via its properties it would work:

{#each $planets as planet}<Planet {...planet}/>{/each}

or

{#each $planets as planet}<Planet name={planet.name}/>{/each}

The way I recommend doing it is to just pass in the identifier:

<script>
$: planets = Planets.find({}, {fields: {_id: 1}});
</script>
{#each $planets as planet (planet._id)}<Planet id={planet._id}/>{/each}

And then in the Planet component, do something like this:

export let id;
$: planet = useTracker(() => Planets.findOne(id));

That makes sure that you have a reactive $planet store available in the Planet component that does update when its properties change.

from svelte-meteor-data.

skandragon avatar skandragon commented on June 14, 2024

Sounds good, thanks!

from svelte-meteor-data.

Related Issues (13)

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.