Skip to content

Commit

Permalink
Revert "feat: replay option for RxReq"
Browse files Browse the repository at this point in the history
This reverts commit 74679ed.
  • Loading branch information
penpenpng committed Jan 14, 2025
1 parent 74679ed commit c909758
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 124 deletions.
73 changes: 0 additions & 73 deletions packages/core/src/__test__/rx-req-replay.test.ts

This file was deleted.

62 changes: 11 additions & 51 deletions packages/core/src/rx-nostr/rx-req.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import * as Nostr from "nostr-typedef";
import {
Observable,
of,
type OperatorFunction,
ReplaySubject,
Subject,
} from "rxjs";
import { Observable, of, type OperatorFunction, Subject } from "rxjs";

import { LazyFilter, ReqPacket } from "../packet.js";

Expand Down Expand Up @@ -156,12 +150,6 @@ const createRxReq = <S extends RxReqStrategy>(params: {
};
};

export interface RxBackwardReqOptions {
/** @deprecated */
rxReqId?: string;
replay?: boolean;
}

/**
* Create a RxReq instance based on the backward strategy.
* It is useful if you want to retrieve past events that have already been published.
Expand All @@ -174,32 +162,15 @@ export interface RxBackwardReqOptions {
* For more information, see [document](https://penpenpng.github.io/rx-nostr/v1/req-strategy.html#backward-strategy).
*/
export function createRxBackwardReq(
// TODO (v4): remove string format options
options?: string /* for backward compatibility. */ | RxBackwardReqOptions,
rxReqId?: string,
): RxReq<"backward"> &
RxReqEmittable<{ relays: string[] }> &
RxReqOverable &
RxReqPipeable {
if (typeof options === "string") {
const rxReqId = options;
return createRxReq({
strategy: "backward",
rxReqId,
});
} else {
const { rxReqId, replay } = options ?? {};
return createRxReq({
strategy: "backward",
rxReqId,
subject: replay ? new ReplaySubject() : undefined,
});
}
}

export interface RxForwardReqOptions {
/** @deprecated */
rxReqId?: string;
replay?: boolean;
return createRxReq({
strategy: "backward",
rxReqId,
});
}

/**
Expand All @@ -215,23 +186,12 @@ export interface RxForwardReqOptions {
* For more information, see [document](https://penpenpng.github.io/rx-nostr/v1/req-strategy.html#forward-strategy).
*/
export function createRxForwardReq(
// TODO (v4): remove string format options
options?: string /* for backward compatibility. */ | RxForwardReqOptions,
rxReqId?: string,
): RxReq<"forward"> & RxReqEmittable & RxReqPipeable {
if (typeof options === "string") {
const rxReqId = options;
return createRxReq({
strategy: "forward",
rxReqId,
});
} else {
const { rxReqId, replay } = options ?? {};
return createRxReq({
strategy: "forward",
rxReqId,
subject: replay ? new ReplaySubject() : undefined,
});
}
return createRxReq({
strategy: "forward",
rxReqId,
});
}

/**
Expand Down

0 comments on commit c909758

Please sign in to comment.