OLD | NEW |
| (Empty) |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 import 'github_services.dart'; | |
6 import 'commit_presenter.dart'; | |
7 | |
8 import 'package:immi/dart/immi.dart'; | |
9 import 'package:immi_samples/sliding_window.dart'; | |
10 | |
11 class CommitListPresenter { | |
12 Repository _repository; | |
13 SlidingWindow _presenter; | |
14 | |
15 CommitListPresenter(this._repository) { | |
16 var commitPresenter = new CommitPresenter(_repository); | |
17 _presenter = new SlidingWindow(commitPresenter); | |
18 } | |
19 | |
20 // TODO(zerny): We should represent methods on nodes in a class structure and | |
21 // support identity-preserving composition. | |
22 Function _displayCache = null; | |
23 Function _wrappedDisplayCache = null; | |
24 Function _wrapDisplayForPrefetching(Function display) { | |
25 if (display != _displayCache) { | |
26 _displayCache = display; | |
27 _wrappedDisplayCache = (int start, int end) { | |
28 _repository.prefetchCommitsInRange(start, end); | |
29 (display)(start, end); | |
30 }; | |
31 } | |
32 return _wrappedDisplayCache; | |
33 } | |
34 | |
35 SlidingWindowNode present(Node previous) { | |
36 SlidingWindowNode window = _presenter.present(); | |
37 return new SlidingWindowNode( | |
38 window: window.window, | |
39 startOffset: window.startOffset, | |
40 windowOffset: window.windowOffset, | |
41 minimumCount: window.minimumCount, | |
42 maximumCount: window.maximumCount, | |
43 toggle: window.toggle, | |
44 display: _wrapDisplayForPrefetching(window.display)); | |
45 } | |
46 } | |
OLD | NEW |