Skip to content

implement OptionalT #24

@knightpop

Description

@knightpop

Hello, Thanks for making this wonderful library.

When I use this with Promise, I need to map and flatMap inside Optional value.

UseCase is like this.

const pNum = Promise.resolve(Optional.of(1));
const num = await pNum;
const plusOneNum: Optional<number> = num.map(n => n + 1);

If I have OptionalT

const pOTNum = OptionalT.from(Promise.resolve(Optional.of(1)));
const plusOneNum: OptionalT<Promise, number> = pOTNum.map(n => n + 1);
const result = (await plusOneNum.value).get();

You can see detail of OptionT(It's implement in scala, but I think you can understand it!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions