aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/View.pm
diff options
context:
space:
mode:
authormatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2007-11-15 21:12:16 +0000
committermatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2007-11-15 21:12:16 +0000
commit097e844260b8b3443cd44d8295c941f1086845bc (patch)
treed6d80e9e396e3087f8d54cc8528cc3c944a7675b /lib/Reaction/UI/View.pm
parentd193faa5cf46694286c7db654510240db46c9bf5 (diff)
downloadreaction-097e844260b8b3443cd44d8295c941f1086845bc.tar.gz
reaction-097e844260b8b3443cd44d8295c941f1086845bc.zip
move viewport to being %_ arg only, not widget attribute, cache widget construction
Diffstat (limited to 'lib/Reaction/UI/View.pm')
-rw-r--r--lib/Reaction/UI/View.pm13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Reaction/UI/View.pm b/lib/Reaction/UI/View.pm
index 92aa7c5..8f0c265 100644
--- a/lib/Reaction/UI/View.pm
+++ b/lib/Reaction/UI/View.pm
@@ -10,6 +10,7 @@ class View which {
has '_layout_set_cache' => (is => 'ro', default => sub { {} });
has '_widget_class_cache' => (is => 'ro', default => sub { {} });
+ has '_widget_cache' => (is => 'ro', default => sub { {} });
has 'app' => (is => 'ro', required => 1);
@@ -54,15 +55,17 @@ class View which {
my ($self, $rctx, $vp) = @_;
my $layout_set = $self->layout_set_for($vp);
my $widget = $self->widget_for($vp, $layout_set);
- $widget->render($rctx);
+ $widget->render($rctx, { viewport => $vp });
};
implements 'widget_for' => as {
my ($self, $vp, $layout_set) = @_;
- return $self->widget_class_for($layout_set)
- ->new(
- view => $self, viewport => $vp, layout_set => $layout_set
- );
+ return
+ $self->_widget_cache->{$layout_set->name}
+ ||= $self->widget_class_for($layout_set)
+ ->new(
+ view => $self, layout_set => $layout_set
+ );
};
implements 'widget_class_for' => as {