veliovgroup / Meteor-flow-router-title

Change document.title on the fly within flow-router
https://atmospherejs.com/ostrio/flow-router-title
BSD 3-Clause "New" or "Revised" License
25 stars 4 forks source link

Reactive title doesn't work #12

Closed afrokick closed 5 years ago

afrokick commented 5 years ago

Page title doesn't change. Computation runs only one.

Example code for Collection:

import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
import { Mongo } from 'meteor/mongo';

const TestCollection = new Mongo.Collection('testColl', { connection: null });

Meteor.setInterval(() => {
  if (TestCollection.find({}).count()) {
    TestCollection.remove({});
  } else {
    TestCollection.insert({ counter: true });
  }
}, 1000);

Tracker.autorun(() => {
  const [s] = TestCollection.find({}).fetch();

  console.log(`Tracker: ${s ? 'founded' : 'not founded'}`);
});

FlowRouter.route('*', {
  name: 'App.notFound',
  action() {
    console.log('rendered');
  },
  title() {
    const [s] = TestCollection.find({}).fetch();

    return s ? 'founded' : 'not founded';
  },
});

Example code 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}`;
  },
});

Env:

afrokick commented 5 years ago

13 possible bugfix

dr-dimitru commented 5 years ago

Hello @afrokick 👋 Thank you for your contribution, released as v3.2.0. Feel free to reopen it in case if the issue is still persists on your end.