Effect CommunityEC
Effect Communityβ€’2y agoβ€’
7 replies
Stephen Bluck

Improving TypeScript Code with Combinators for Credential Verification

any other combinators I am missing to make this a little nicer?
Ref.get(this.state).pipe(
  Effect.flatMap((state) => state.findCredentialsByEmail(email)),
  Effect.flatMap((secure) =>
    // I am not a fan of this bit 
    Effect.if(this.match(password, secure.password), {
      onTrue: this.findByEmail(email),
      onFalse: new Credentials.NotRecognised(),
    }),
  ),
)
Was this page helpful?