Comments (2)
Hey! This would be better addressed in our discord, you're welcome to join
interruptions are handled within effect, meaning I don't believe you will need to handle the error raised by the interruption explicitly.
export interface MemoryFile {
path: string;
contentType: string;
getBody: () => Promise<Readable>;
}
export class UploadError extends Data.taggedClass("UploadError")<{ reason: unknown }>{}
export const streamFileToS3 = (file: MemoryFile) =>
// You don't have to explicitly type the operator, most of effect has very strong inference you can rely on
Effect.tryPromise({
// the signature here is <A>(signal: AbortSignal) => Promise<A>
// so you can skip the async await
try: (signal) =>
new Upload({
client: s3Client,
params: {
Bucket: My_BUCKET,
Key: file.path,
ContentType: file.contentType,
ACL: "public-read",
Body: await file.getBody(),
},
abortController: awsAbortController(signal),
}).done(),
// the `catch` here is mostly used for mapping the error from the operation so it's no longer `unknown`.
// It's perfectly reasonable to just create a wrapper, I can explain in more detail in the discord if you want
catch: (reason) => new UploadError({ reason })
});
export const awsAbortController = (signal: AbortSignal): any => ({
signal,
abort: () => {},
});
from effect.
Related Issues (20)
- Include tsconfig files with each node module HOT 1
- Integrate tsplus-gen into the build step
- A single file prelude suggestion
- Peer dependencies
- Prelude idea
- Decorators as in returns HOT 1
- [Question] Looking for structures. HOT 1
- Type-checking error HOT 1
- [Suggestion] Pipe function improvement
- [Suggestion] Optional `this` context for `Effect.gen` HOT 1
- The thing with abstracted away promises HOT 4
- Quickstart instructions are outdated HOT 4
- [ReadOnlyArray] Array.isEmptyArray does not perform type narrowing HOT 3
- Effect and stack overflow HOT 2
- Consider scheduler-aware cooperative yielding HOT 1
- [platform-node] Process.exitCode and Process.stderr/stdout cannot be accessed sequentially HOT 1
- `npm init effect` HOT 2
- Target invocation illegal exception HOT 2
- Rename Hub to PubSub
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from effect.