meteor/agent-skills

meteor-pubsub

Use when authoring or debugging Meteor publications and subscriptions (Meteor.publish, Meteor.subscribe).

소스 보기

사용 방법

  1. 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
  2. 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
  3. 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/meteor/agent-skills --skill meteor-pubsub

시작 전 확인

  • 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
  • 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 Skill 문서

원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.

Meteor publications and subscriptions

Publications stream a set of documents to subscribed clients and keep them live. The publication is the only place server-side authorization can filter rows before they reach the client.

Decision flow

  1. Does the client need this data reactively? If no, prefer a method (one-shot

read). If yes, use a publication.

  1. Is the data user-specific? Filter by this.userId inside the publish

function. Without that filter, documents leak across users.

  1. Can the publication be expressed as a single cursor? Return it directly.
  2. Does it need one async lookup before choosing a cursor? Use an async

publish handler, await the lookup, then return the cursor.

  1. Does it need per-document async joins, custom aggregation output, or an

external reactive source? Drop to the low-level this.added / this.changed / this.removed API.

Scaffold

javascript
import { Meteor } from "meteor/meteor";
import { Items } from "/imports/api/items";

Meteor.publish("items.mine", function () {
  if (!this.userId) {
    return this.ready();
  }
  return Items.find(
    { ownerId: this.userId },
    { fields: { title: 1, qty: 1, updatedAt: 1 }, sort: { updatedAt: -1 } },
  );
});

Project fields whenever the collection contains columns the subscriber must not receive.

Async publish handlers may also return a cursor:

javascript
Meteor.publish("items.byTeam", async function (teamId) {
  const member = await Memberships.findOneAsync({
    teamId,
    userId: this.userId,
  });
  if (!member) return this.ready();
  return Items.find({ teamId }, { fields: { title: 1, qty: 1 } });
});

Meteor awaits the handler before processing the returned cursor.

Subscribing

javascript
import { Meteor } from "meteor/meteor";

const handle = Meteor.subscribe("items.mine");
// React / Blaze / Svelte hooks observe handle.ready() and the local cursor.
handle.stop();

Publication strategies

Set per-collection with Meteor.server.setPublicationStrategy. Three options:

javascript
import { DDPServer } from "meteor/ddp-server";

Meteor.server.setPublicationStrategy(
  "items",
  DDPServer.publicationStrategies.NO_MERGE,
);
StrategyWhen to use
SERVER_MERGEDefault. Tracks merged document fields across publications and sends deltas.
NO_MERGETracks sent document IDs so unsubscribe can remove them. Use when the collection is owned by one publication.
NO_MERGE_NO_HISTORYRemembers nothing and sends no removals on stop. Reserve for send-and-forget queues where stale client documents are intentional.

See references/publication-strategies.md.

Low-level publish API

For joins or async work:

javascript
Meteor.publish("feed", async function () {
  const cursor = Posts.find({}, { fields: { title: 1, authorId: 1 } });
  const observer = await cursor.observeChangesAsync({
    added: async (id, doc) => {
      const author = await Users.findOneAsync(doc.authorId, {
        fields: { username: 1 },
      });
      this.added("feed", id, { ...doc, authorName: author?.username });
    },
    changed: (id, changes) => this.changed("feed", id, changes),
    removed: (id) => this.removed("feed", id),
  });

  this.ready();
  this.onStop(() => observer.stop());
});

Note: cursor transform functions remain synchronous. Use a separate publication or the low-level API for per-document async joins.

Live observer delivery does not wait for one async callback before later changes arrive. If ordering or backpressure matters, serialize the work with a per-subscription Promise queue. Attach an error policy and stop the observer from this.onStop; see references/low-level-publish-api.md.

Anti-patterns

  • Publish without a this.userId filter when data is user-specific.
  • Publish sensitive or unnecessary columns. Add a fields projection when

the full document is not part of the publication contract.

  • Confuse an async publish handler with an async cursor transform. Meteor

awaits the handler Promise, but each transform callback must return a document synchronously.

  • Use cursor transforms for async joins. Transforms are synchronous; the

low-level API is the right tool.

  • Subscribe to large unbounded collections. Page the data with limit/skip.

See also

  • references/publication-strategies.md
  • references/low-level-publish-api.md
  • references/eval-cases.md

관련 작업

같은 저장소의 Skills

더 많은 Skills

모든 Skills
meteor
커뮤니티

meteor-cli-installation

Use when installing, locating, repairing, resetting, or uninstalling the Meteor CLI for Meteor 3 development. Triggers on "meteor: command not found", npx meteor, installer failures, PATH problems, specific Meteor versions, clean reinstall requests, meteor reset, or corrupted dev bundles. Use this skill when the user asks about fresh workstation setup or making a local Meteor command available. For application failures after the CLI starts, use meteor-debugging; for application code upgrades, us

설치 수
1
GitHub Stars
10
업데이트
10월 14일
meteor
커뮤니티

meteor-debugging

Use when diagnosing an unexplained failure in a Meteor 3 application before the failing layer or fix is known. Triggers on server crashes, client-only errors, stuck subscriptions, DDP or WebSocket disconnects, Minimongo/server data mismatches, hanging or flaky tests, slow builds, --inspect, console.log, .only, Playwright traces, Instrumentation lifecycle events, or requests to debug a Meteor app. Use this skill when evidence must distinguish Meteor tool, server, client, data, test, browser, mobi

설치 수
1
GitHub Stars
10
업데이트
10월 14일
meteor
커뮤니티

meteor-methods

Use when authoring or debugging Meteor methods (Meteor.methods, Meteor.call, Meteor.callAsync). Triggers on argument validation with check(), optimistic UI stubs, latency compensation, Meteor.Error handling, and DDPRateLimiter. Use this skill when the user asks about server-side mutation, asks about rate limiting RPC, or asks about wrapping a method with auth checks.

설치 수
1
GitHub Stars
10
업데이트
10월 14일
meteor
커뮤니티

migrate-to-rspack

Use when migrating an existing Meteor app to Rspack (Meteor 3.4+), or upgrading Rspack 1 to 2 on Meteor 3.6 beta. Triggers on nested imports, mainModule entry points, server-only apps, replacing fourseven:scss / meteor/less / coffeescript / jorgenvatle:vite / zodern:melte with loaders, Svelte/TypeScript preprocessing or Lingui SWC plugin failures after upgrade, CommonJS default-import interop, module.exports in client graphs, Node built-ins in browser code, build / build-assets / build-chunks, .

설치 수
1
GitHub Stars
10
업데이트
10월 14일