MoobX::Observer - a MoobX object reacting to observable variable changes
version 0.1.2
use MoobX; use MoobX::Observer; observable( my $foo = 'hi' ); my $obs = MoobX::Observer->new( generator => sub { scalar reverse $foo } ); $foo = 'hello'; say $obs; # prints 'olleh'
This class implements the observer object used by MoobX.
MoobX::Observer objects are stringified using their value attribute.
value
my $obs = MoobX::Observer->new( generator => sub { ... }, autorun => 1, );
Constructor. Accepts two arguments:
Function generating the observer value. Required.
If set to true, the observer will eagerly compute its value at creation time, and recompute it as soon as a dependency changes. Defaults to false.
false
Returns the currently cached observer's value.
Yanick Champoux <yanick@cpan.org>
This software is copyright (c) 2022, 2017 by Yanick Champoux.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install MoobX, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MoobX
CPAN shell
perl -MCPAN -e shell install MoobX
For more information on module installation, please visit the detailed CPAN module installation guide.