Last active
May 19, 2023 10:07
-
-
Save jeiea/74d7e79b0ff566d2d847561d9af708a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ObjectExt<T> on T { | |
R let<R>(R Function(T) x) => x(this); | |
} | |
class ProgramCardDataFamily { | |
const ProgramCardDataFamily(); | |
ProgramCardDataProvider call( int data) { | |
return ProgramCardDataProvider( data); | |
} | |
} | |
abstract class Provider<T> { | |
T read(); | |
} | |
class ProgramCardDataProvider implements Provider<int> { | |
ProgramCardDataProvider( this.data); | |
final int data; | |
@override | |
int read() { | |
return data; | |
} | |
} | |
T watch<T>(Provider<T> provider) { | |
return provider.read(); | |
} | |
void main() async { | |
int? data = 3; | |
print('a'); | |
data.let(ProgramCardDataFamily()).let(watch); | |
print('b'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment