Skip to content

Add Pipeable.Class api #4669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 30, 2025
Merged

Conversation

KhraksMamtsov
Copy link
Contributor

@KhraksMamtsov KhraksMamtsov commented Mar 30, 2025

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Simplified the creation of pipeable classes with Pipeable.Class() mixin

class MyClass extends Pipeable.Class() {
  constructor(public a: number) {
    super()
  }
  methodA() {
    return this.a
  }
}
console.log(new MyClass(2).pipe((x) => x.methodA())) // 2
class A {
  constructor(public a: number) {}
  methodA() {
    return this.a
  }
}
class B extends Pipeable.Class(A) {
  constructor(private b: string) {
    super(b.length)
  }
  methodB() {
    return [this.b, this.methodA()]
  }
}
console.log(new B("pipe").pipe((x) => x.methodA())) // ['pipe', 4]

Related

https://discord.com/channels/795981131316985866/795983589644304396/1355973562476925122

  • Related Issue #
  • Closes #

Copy link

changeset-bot bot commented Mar 30, 2025

🦋 Changeset detected

Latest commit: bb2afb9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 32 packages
Name Type
effect Minor
@effect/cli Major
@effect/cluster Major
@effect/experimental Major
@effect/opentelemetry Major
@effect/platform-browser Major
@effect/platform-bun Major
@effect/platform-node-shared Major
@effect/platform-node Major
@effect/platform Major
@effect/printer-ansi Major
@effect/printer Major
@effect/rpc Major
@effect/sql-clickhouse Major
@effect/sql-d1 Major
@effect/sql-drizzle Major
@effect/sql-kysely Major
@effect/sql-libsql Major
@effect/sql-mssql Major
@effect/sql-mysql2 Major
@effect/sql-pg Major
@effect/sql-sqlite-bun Major
@effect/sql-sqlite-do Major
@effect/sql-sqlite-node Major
@effect/sql-sqlite-react-native Major
@effect/sql-sqlite-wasm Major
@effect/sql Major
@effect/typeclass Major
@effect/vitest Major
@effect/ai Major
@effect/ai-anthropic Major
@effect/ai-openai Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-bot effect-bot changed the base branch from main to next-minor March 30, 2025 20:37
return [this.b, this.methodA()]
}
}
console.log(new B("pipe").pipe((x) => x.methodA())) // ['pipe', 4]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this example was intending to show x.methodB()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes) Fixed

@effect-bot effect-bot force-pushed the next-minor branch 5 times, most recently from 65f159e to 36f2f6d Compare March 31, 2025 05:37
@mikearnaldi
Copy link
Member

We could make Pipeable.Class() and Pipeable.Class(Base) instead of two

@KhraksMamtsov
Copy link
Contributor Author

We could make Pipeable.Class() and Pipeable.Class(Base) instead of two

Done

@effect-bot effect-bot force-pushed the next-minor branch 16 times, most recently from 43ed675 to e21bf12 Compare April 3, 2025 22:36
@github-project-automation github-project-automation bot moved this from Discussion Ongoing to Done in PR Backlog Apr 30, 2025
@effect-bot effect-bot mentioned this pull request Apr 30, 2025
effect-bot pushed a commit that referenced this pull request Apr 30, 2025
effect-bot pushed a commit that referenced this pull request Apr 30, 2025
effect-bot pushed a commit that referenced this pull request May 1, 2025
effect-bot pushed a commit that referenced this pull request May 1, 2025
effect-bot pushed a commit that referenced this pull request May 1, 2025
effect-bot pushed a commit that referenced this pull request May 1, 2025
effect-bot pushed a commit that referenced this pull request May 2, 2025
effect-bot pushed a commit that referenced this pull request May 5, 2025
effect-bot pushed a commit that referenced this pull request May 5, 2025
effect-bot pushed a commit that referenced this pull request May 5, 2025
effect-bot pushed a commit that referenced this pull request May 5, 2025
effect-bot pushed a commit that referenced this pull request May 6, 2025
effect-bot pushed a commit that referenced this pull request May 6, 2025
effect-bot pushed a commit that referenced this pull request May 6, 2025
effect-bot pushed a commit that referenced this pull request May 6, 2025
effect-bot pushed a commit that referenced this pull request May 6, 2025
effect-bot pushed a commit that referenced this pull request May 7, 2025
effect-bot pushed a commit that referenced this pull request May 7, 2025
effect-bot pushed a commit that referenced this pull request May 8, 2025
effect-bot pushed a commit that referenced this pull request May 8, 2025
effect-bot pushed a commit that referenced this pull request May 8, 2025
effect-bot pushed a commit that referenced this pull request May 9, 2025
effect-bot pushed a commit that referenced this pull request May 9, 2025
effect-bot pushed a commit that referenced this pull request May 9, 2025
effect-bot pushed a commit that referenced this pull request May 9, 2025
effect-bot pushed a commit that referenced this pull request May 11, 2025
effect-bot pushed a commit that referenced this pull request May 11, 2025
tim-smart pushed a commit that referenced this pull request May 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants