GithubHelp home page GithubHelp logo

veliovgroup / meteor-flow-router-title Goto Github PK

View Code? Open in Web Editor NEW
25.0 5.0 4.0 102 KB

Change document.title on the fly within flow-router

Home Page: https://atmospherejs.com/ostrio/flow-router-title

License: BSD 3-Clause "New" or "Revised" License

JavaScript 100.00%
meteor-package meteorjs flow-router meteor seo seo-meta page-title title

meteor-flow-router-title's Issues

Reactive title doesn't work

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:

Duplicate ReactiveDict name: activeRouteConfig

Meteor version 1.4.4.1

Duplicate ReactiveDict name: activeRouteConfig error begins to show as soon as Meteor flow router title was added with meteor add ostrio:flow-router-title (even without any code level changes).

Plugin still seems to work once the required code is added in FlowRouter routes, the error still persists.

screen shot 2017-06-07 at 17 46 50

TypeError: FlowRouterTitle is not a constructor

Trying to use this library for the first time.
The extra package (dependency) works without issues.
I can also import this package.
I removed the original FlowRouter packages (as per the instructions).

But when I add this line to instantiate it, as per the docs, I get the error "TypeError: FlowRouterTitle is not a constructor"

import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
import {FlowRouterTitle} from 'meteor/ostrio:flow-router-title';
[I DECLARE SOME ROUTES HERE]
new FlowRouterTitle(FlowRouter);  <-- THROWS ERROR

Latest flow-router-title version
Meteor 2.8.1 (latest)
Chrome
Mac

Title don't reactive with TAPi18n?

Title don't reactive

title: function () {
        return TAPi18n.__('core.exchange.title');
    },

I try to change language in the same route, it don't reactive.

[request] recursively search ancestor groups

a titlePrefix and default title will affect all routes in a group, but not routes in a child groups group. It would be great to set these properties for the whole app through a single global group. Thanks!

route title not reactive

I have found that the title function is not reactive-sensitive. my test ( have subbed out the post title with "my blog" for now:

This prints undefined then my blog post name, demonstrating reactivity.

blogSection.route('/:date/:postTitle/', {
    name: 'Post',
    title: function(params){
        Tracker.autorun(()=>{
            var blog = Blog.findOne({
                name: "My Blog",
            });
            console.log("route: ",blog && blog.name); // TODO remove

        })

    },

this prints undefined, and does not set the title to the blog name. If this function were reactive it would as per the example above

blogSection.route('/:date/:postTitle/', {
    name: 'Post',
    title: function(params){
            var blog = Blog.findOne({
                name: "My Blog",
            });
            console.log("route: ",blog && blog.name); 
                        return blog.name;
    },

FlowRouterTitle undefined

This is what I get after meteor add and using "new FlowRouterTitle" after I have created all the routes. Any idea why? Maybe I am doing something wrong? I am declaring all the routes in a jsx file.

W20160423-23:58:04.011(2)? (STDERR)
W20160423-23:58:04.012(2)? (STDERR) /home/giordano/.meteor/packages/meteor-tool/.1.3.0_3.a5p6a8++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:267
W20160423-23:58:04.013(2)? (STDERR) throw(ex);
W20160423-23:58:04.013(2)? (STDERR) ^
W20160423-23:58:04.196(2)? (STDERR) ReferenceError: FlowRouterTitle is not defined
W20160423-23:58:04.197(2)? (STDERR) at meteorInstall.app.routes.jsx (app/routes.jsx:80:5)
W20160423-23:58:04.197(2)? (STDERR) at fileEvaluate (packages/modules-runtime.js:158:9)
W20160423-23:58:04.198(2)? (STDERR) at require (packages/modules-runtime.js:92:16)
W20160423-23:58:04.198(2)? (STDERR) at /home/giordano/git/shopluxurystyles/.meteor/local/build/programs/server/app/app.js:4092:1
W20160423-23:58:04.198(2)? (STDERR) at /home/giordano/git/shopluxurystyles/.meteor/local/build/programs/server/boot.js:283:10
W20160423-23:58:04.199(2)? (STDERR) at Array.forEach (native)
W20160423-23:58:04.199(2)? (STDERR) at Function..each..forEach (/home/giordano/.meteor/packages/meteor-tool/.1.3.0_3.a5p6a8++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20160423-23:58:04.199(2)? (STDERR) at /home/giordano/git/shopluxurystyles/.meteor/local/build/programs/server/boot.js:133:5
=> Exited with code: 8

Route title function isn't reactive

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. The title() function should run again when the cursor isn't empty anymore. Also tried with some Session.get() tests, nothing happens neither.

Thanks.

NB. This follows #6

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.