Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@adrian-2414745
Copy link
Contributor

@adrian-2414745 adrian-2414745 commented Apr 13, 2025

Just like ZLayer.fromFunction.

The main pain point which triggered me was that in ZIO test i had to access all services individually

test() {
  a <- ZIO.service[A]
  b <- ZIO.service[b]
  // use a and b
}

now it is possible to get many services in one go

test() { 
  ZIO.fromFunction { (a: A, b: B) =>
     //use a and b
  }
}

@CLAassistant
Copy link

CLAassistant commented Apr 13, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@kyri-petrou kyri-petrou left a comment

Choose a reason for hiding this comment

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

Love it! Too bad we'll have overlap between ZIO.serviceWith and ZIO.fromFunction for the Function1 case but I think that should be OK

@kyri-petrou
Copy link
Contributor

One more comment: Can we rename this method to fromFunctionZIO to keep naming aligned with ZIO.fromServiceZIO? We potentially want to also add fromFunction where the method something that is not effectual.

@adrian-2414745 adrian-2414745 force-pushed the series/2.x branch 3 times, most recently from 0fb8d38 to 567c671 Compare April 15, 2025 08:21
Copy link
Collaborator

@hearnadam hearnadam left a comment

Choose a reason for hiding this comment

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

Change overall LGTM - though it appears you had a faulty merge, including some other commits in your history.

@adrian-2414745

This comment was marked as outdated.

@adrian-2414745 adrian-2414745 force-pushed the series/2.x branch 2 times, most recently from 8cee651 to b81d3fd Compare April 15, 2025 14:07
@adrian-2414745

This comment was marked as resolved.

@hearnadam
Copy link
Collaborator

@adrian-2414745 can you run fmt?

@adrian-2414745

This comment was marked as outdated.


type WithOut[In, Out0] = ZIOFunctionConstructor[In] { type Out = Out0 }

implicit def function1Constructor[A: Tag, R, E, Z: Tag]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you missed my previous comment. The : Tag on Z is unnecessary as far as I can tell (in this and other methods)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

missed it. done

Copy link
Contributor

@kyri-petrou kyri-petrou left a comment

Choose a reason for hiding this comment

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

Thank you! Looks like a great addition!

@kyri-petrou kyri-petrou merged commit 8da126a into zio:series/2.x Apr 21, 2025
18 checks passed
@kyri-petrou kyri-petrou changed the title Add ZIO.fromFunction Add ZIO.fromFunctionZIO Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants