Comments (24)
I might have spoke too fast... Looks like it was working because I already subscribed to needed datas.
Further tests aren't successful, I reduced the issue to a simple test:
FlowRouter.route('/test', {
name: 'test',
title: function() {
return Session.get('test')
}
});
Setting new values like Session.set('test', 'foo')
never fires the function again. Did I miss something obvious?
from meteor-flow-router-title.
Yes, I'll work on your issues soon, hope to put my hands on before end of this week.
Ping me if I won't response for more than week, can forget, sorry... to busy right now
from meteor-flow-router-title.
@jdmswong I took a look on demo, and code of this package. Reactive data-source should work.
As in this example, i18n.get()
returns ReactiveVar
and title is updated.
FlowRouter.route('/me/account', {
name: 'account',
title: function() {
// In this example we used `ostrio:i18n` package
return i18n.get('account.document.title');
}
});
So, could you please try:
blogSection.route('/:date/:postTitle/', {
name: 'Post',
title: function(params){
var blog = Blog.find({
name: "My Blog",
}).fetch();
if (blog[0] && blog[0].name) {
return blog[0].name;
} else {
return "Loading....";
}
}
});
from meteor-flow-router-title.
we're supposed to do component-based subscriptions
Got it now.
Well, as soon as data will be available on the cursor, no matter where subscription is called, a title will be updated as stated here.
from meteor-flow-router-title.
you have to add waitOn
for subscription to be ready
from meteor-flow-router-title.
https://github.com/VeliovGroup/flow-router#waiton-hook
from meteor-flow-router-title.
@jdmswong yes, it solved this issue?
from meteor-flow-router-title.
I didn't want the page to wait on the subscription being ready, so I displayed something else in the title. Out of curiosity are there any plans to make the title function reactive in the future?
from meteor-flow-router-title.
I did, the title stays at "Loading..."
from meteor-flow-router-title.
To make sure, type this into browser's console:
Blog.find({name: "My Blog"}).fetch()
from meteor-flow-router-title.
It returns the blog as expected, additionally the page itself is populated with the correct data
from meteor-flow-router-title.
Okay, I'll take look
from meteor-flow-router-title.
Hi @jdmswong ,
Sorry for delay, but if you still having this issue could you please test it on latest release?
from meteor-flow-router-title.
@jdmswong any news on your end?
from meteor-flow-router-title.
Closed due to silence at issue owner end.
Feel free to reopen it in case if issue still persists on your end.
from meteor-flow-router-title.
It's an interesting issue because we're supposed to do component-based subscriptions, but title
is one of the thing that could not easily be managed at this level. I don't want to block routing with waitOn
too. Do you settled on any other solution since then? Thanks.
from meteor-flow-router-title.
@nicooprat using data
hook. But anyways you probably will end up using waitOn
.
Why you're afraid to use waitOn
hook?
from meteor-flow-router-title.
You're right, using .find().fetch()[0]
is reactive unlike doing .findOne()
. Didn't think it would be that simple. Sorry for issue bumping, this can be closed again ;) Thanks for your reactivity!
from meteor-flow-router-title.
@nicooprat I wish you to find a solution to fit your needs.
Ping me if you will have more questions.
from meteor-flow-router-title.
@jdmswong this might not work with Sessions.
Could you create separate issue with request to support reactive Sessions?
from meteor-flow-router-title.
Actually I tried with Session to be sure, because it's the simplest reactive thing I could think of, but doing it with cursors didn't work too. I can create a new issue but I think it's still the same problem... Here's a example of route definition:
FlowRouter.route('/:storyId', {
name: 'story',
title({storyId}) {
// This is only fired once, cursors are empty
// Subscriptions are done in templates
// When data is available, this doesn't run again
const story = Stories.find(storyId).fetch()[0]
return story && story.title
},
action: function(params, queryParams) {
BlazeLayout.render(...)
}
})
I also tried const story = Stories.find(storyId).fetch()
(without [0]
), or even const story = Stories.find(storyId)
, no luck.
from meteor-flow-router-title.
I can create a new issue but I think it's still the same problem... Here's a example of route definition:
Yes, that will be great. You can make it more generous - to fix reactive sources.
from meteor-flow-router-title.
It doesn't work for ReactiveVar.
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
const test = new ReactiveVar(1);
Meteor.setInterval(() => {
test.set(test.get() + 1);
console.log(`new:${test.get()}`);
}, 1000);
FlowRouter.route('*', {
name: 'Test.name',
action() {
console.log('rendered');
},
title() {
const t = test.get();
console.log(`change title:${t}`);
return `count ${t}`;
},
});
from meteor-flow-router-title.
Hello @afrokick
Please make sure youβre on the latest meteor and package releases.
Itβs better to create new issue thread as this one is closed. Please follow our ISSUE_TEMPLATE when you create a new issue.
from meteor-flow-router-title.
Related Issues (11)
- Could I use this with Meteor 1.3? HOT 2
- Reactive title doesn't work HOT 2
- TypeError: FlowRouterTitle is not a constructor HOT 1
- Could I use with `React`? HOT 3
- FlowRouterTitle undefined HOT 5
- Title don't reactive with TAPi18n? HOT 4
- [request] recursively search ancestor groups HOT 5
- "SyntaxError: Unexpected token export" in browsers in ostrio_flow-router-title.js HOT 9
- Duplicate ReactiveDict name: activeRouteConfig HOT 6
- Route title function isn't reactive HOT 16
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 meteor-flow-router-title.