GithubHelp home page GithubHelp logo

Comments (24)

nicooprat avatar nicooprat commented on May 29, 2024 2

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.

dr-dimitru avatar dr-dimitru commented on May 29, 2024 1

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.

dr-dimitru avatar dr-dimitru commented on May 29, 2024 1

@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.

dr-dimitru avatar dr-dimitru commented on May 29, 2024 1

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.

dr-dimitru avatar dr-dimitru commented on May 29, 2024

you have to add waitOn for subscription to be ready

from meteor-flow-router-title.

jdmswong avatar jdmswong commented on May 29, 2024

https://github.com/VeliovGroup/flow-router#waiton-hook

from meteor-flow-router-title.

dr-dimitru avatar dr-dimitru commented on May 29, 2024

@jdmswong yes, it solved this issue?

from meteor-flow-router-title.

jdmswong avatar jdmswong commented on May 29, 2024

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.

jdmswong avatar jdmswong commented on May 29, 2024

I did, the title stays at "Loading..."

from meteor-flow-router-title.

dr-dimitru avatar dr-dimitru commented on May 29, 2024

To make sure, type this into browser's console:

Blog.find({name: "My Blog"}).fetch()

from meteor-flow-router-title.

jdmswong avatar jdmswong commented on May 29, 2024

It returns the blog as expected, additionally the page itself is populated with the correct data

from meteor-flow-router-title.

dr-dimitru avatar dr-dimitru commented on May 29, 2024

Okay, I'll take look

from meteor-flow-router-title.

dr-dimitru avatar dr-dimitru commented on May 29, 2024

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.

dr-dimitru avatar dr-dimitru commented on May 29, 2024

@jdmswong any news on your end?

from meteor-flow-router-title.

dr-dimitru avatar dr-dimitru commented on May 29, 2024

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.

nicooprat avatar nicooprat commented on May 29, 2024

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.

dr-dimitru avatar dr-dimitru commented on May 29, 2024

@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.

nicooprat avatar nicooprat commented on May 29, 2024

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.

dr-dimitru avatar dr-dimitru commented on May 29, 2024

@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.

dr-dimitru avatar dr-dimitru commented on May 29, 2024

@jdmswong this might not work with Sessions.
Could you create separate issue with request to support reactive Sessions?

from meteor-flow-router-title.

nicooprat avatar nicooprat commented on May 29, 2024

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.

dr-dimitru avatar dr-dimitru commented on May 29, 2024

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.

afrokick avatar afrokick commented on May 29, 2024

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.

dr-dimitru avatar dr-dimitru commented on May 29, 2024

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)

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.