Skip to content
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

Add Lazy type #101

Closed
wants to merge 4 commits into from
Closed

Add Lazy type #101

wants to merge 4 commits into from

Conversation

markuswustenberg
Copy link
Member

@markuswustenberg markuswustenberg commented May 25, 2022

Lazy is a function that returns a Node that is itself also a Node.

Used with If, it enables lazy evaluation of the node to return, depending on the condition passed to If.

See also #99 for a different approach explored.

`Func` is a function that returns a `Node` that is itself also a `Node`.

Used with `If`, it enables lazy evaluation of the node to return, depending on the condition passed to `If`.

See also #99 for a different approach explored.
@codecov
Copy link

codecov bot commented May 25, 2022

Codecov Report

Merging #101 (b6265a1) into master (c868c52) will not change coverage.
The diff coverage is 100.00%.

❗ Current head b6265a1 differs from pull request most recent head 6e4a63f. Consider uploading reports for the commit 6e4a63f to get more accurate results

@@            Coverage Diff            @@
##            master      #101   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            9         9           
  Lines          491       493    +2     
=========================================
+ Hits           491       493    +2     
Impacted Files Coverage Δ
gomponents.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c868c52...6e4a63f. Read the comment docs.

@oderwat
Copy link
Contributor

oderwat commented May 25, 2022

This is a neat trick. I like this kind of lazy evaluation as it also works for if/else and even for something as MaybeString(v *string,func(v string) g.Node)

@markuswustenberg
Copy link
Member Author

Yeah, I think I like this solution too. Useful anywhere where lazy node evaluation could be nice. Maybe I should just call it Lazy.

@markuswustenberg markuswustenberg changed the title Add Func type Add Lazy type May 27, 2022
@markuswustenberg
Copy link
Member Author

Hmm. Sadly this doesn't work for attributes. I'll have to rethink a bit.

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.

None yet

2 participants