I’m confused, does the client have access to server-side-only methods or publish functions that live inside the imports/server directory?
For example in the todos example:
todos/imports/api/lists/server/publications.js
import { Meteor } from 'meteor/meteor';
import { Lists } from '../lists.js';
Meteor.publish('lists.public', function listsPublic() {
return Lists.find({
userId: { $exists: false },
}, {
fields: Lists.publicFields,
});
});
Meteor.publish('lists.private', function listsPrivate() {
if (!this.userId) {
return this.ready();
}
return Lists.find({
userId: this.userId,
}, {
fields: Lists.publicFields,
});
});
Could this be consumed by a client only UI view or component via a Meteor.Method call or a Subcribe method (right now I use Blaze, but plan to update to React in the future if that matters any)? Right now, without my Meteor Methods or Publish functions OUTSIDE of import, yet inside a server only directory, I don’t have to worry that my UI has access to this server only stuff.
In the todos example the publish is only consumed by a “shared” file:
/todos/imports/ui/layouts/app-body.js
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { ReactiveDict } from 'meteor/reactive-dict';
import { Template } from 'meteor/templating';
import { ActiveRoute } from 'meteor/zimme:active-route';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { TAPi18n } from 'meteor/tap:i18n';
import { T9n } from 'meteor/softwarerero:accounts-t9n';
import { _ } from 'meteor/underscore';
import { $ } from 'meteor/jquery';
import { Lists } from '../../api/lists/lists.js';
import { insert } from '../../api/lists/methods.js';
import '../components/loading.js';
import './app-body.html';
const CONNECTION_ISSUE_TIMEOUT = 5000;
// A store which is local to this file?
const showConnectionIssue = new ReactiveVar(false);
Meteor.startup(() => {
// Only show the connection error box if it has been 5 seconds since
// the app started
setTimeout(() => {
// FIXME:
// Launch screen handle created in lib/router.js
// dataReadyHold.release();
// Show the connection error box
showConnectionIssue.set(true);
}, CONNECTION_ISSUE_TIMEOUT);
});
Template.App_body.onCreated(function appBodyOnCreated() {
this.subscribe('lists.public');
this.subscribe('lists.private');
this.state = new ReactiveDict();
this.state.setDefault({
menuOpen: false,
userMenuOpen: false,
});
});
Also, I couldn’t really find an example of Meteor.Methods in used, is this something we should still use?