Comments (4)
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.
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.
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.
Sounds good, thanks!
from svelte-meteor-data.
Related Issues (13)
- Auto-stop cursor.observe and cursor.observeChanges
- meteor/reactive-dict HOT 1
- await Meteor.subscribe doesn't work? HOT 1
- Would you consider releasing a separate package with the svelte meteor helper functions? HOT 2
- Make svelte:compiler a weak dependency HOT 5
- Expose Session variables as Svelte store
- Make Tracker.autorun work inside $: HOT 1
- Tracker.autorun does not work inside onMount as of 0.2.0 HOT 1
- A reactive subscription creates infinite amount of subscriptions when props change HOT 3
- benefit of calling useTracker HOT 2
- Is there a benefit to using useSession versus a regular svelte store? HOT 1
- Meteor user data not updated using useTracker HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte-meteor-data.