graph-gophers / dataloader

Implementation of Facebook's DataLoader in Golang
MIT License
1.2k stars 75 forks source link

Question: why return a thunk? #107

Closed fiatjaf closed 7 months ago

fiatjaf commented 1 year ago

This is probably a stupid question, but I don't understand why .Load() returns a thunk function and not just the results directly. If the examples show we should just call the thunk function immediately, what is the difference?

I feel I'm missing some important architectural design here.

eaglemoor commented 1 year ago

It's a nodejs implementation. .Load return lambda function for don't have mutex in dataloader side.