-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewModelManagerInterface.php
More file actions
53 lines (45 loc) · 1.31 KB
/
ViewModelManagerInterface.php
File metadata and controls
53 lines (45 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
declare(strict_types=1);
namespace Toppy\AsyncViewModel;
use Amp\Future;
interface ViewModelManagerInterface
{
/**
* Start async fetching for a view model (non-blocking).
*
* @param class-string<AsyncViewModel> $class
*/
public function preload(string $class): void;
/**
* Bulk preload multiple view models.
*
* @param array<class-string<AsyncViewModel>> $classes
*/
public function preloadAll(array $classes): void;
/**
* Get resolved data, blocking if necessary.
*
* Returns a lazy proxy that awaits the Future on first property access.
*
* @template T of object
* @param class-string<AsyncViewModel<T>> $class
* @return T
*/
public function get(string $class): object;
/**
* Start async fetching and return the Future.
*
* @param class-string<AsyncViewModel> $class
* @return Future<object>
*/
public function preloadWithFuture(string $class): Future;
/**
* Get all pending futures and resolved view models.
*
* Returns a combined array of all ViewModels being tracked, whether still
* pending (as Futures) or already resolved (as data objects/lazy proxies).
*
* @return array<class-string, Future<object>|object>
*/
public function all(): array;
}