/
async.dart
43 lines (37 loc) · 1.49 KB
/
async.dart
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
// Copyright 2017 Google Inc. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
import 'dart:async';
import 'package:meta/meta.dart';
import '../exception.dart';
import '../value.dart';
import 'async_built_in.dart';
/// An interface for functions and mixins that can be invoked from Sass by
/// passing in arguments.
///
/// This class represents callables that *need* to do asynchronous work. It's
/// only compatible with the asynchronous `compile()` methods. If a callback can
/// work synchronously, it should be a [Callable] instead.
///
/// See [Callable] for more details.
///
/// {@category Compile}
@sealed
abstract class AsyncCallable {
/// The callable's name.
String get name;
@Deprecated('Use `AsyncCallable.function` instead.')
factory AsyncCallable(String name, String arguments,
FutureOr<Value> callback(List<Value> arguments)) =>
AsyncCallable.function(name, arguments, callback);
/// Creates a callable with the given [name] and [arguments] that runs
/// [callback] when called.
///
/// The argument declaration is parsed from [arguments], which should not
/// include parentheses. Throws a [SassFormatException] if parsing fails.
///
/// See [new Callable] for more details.
factory AsyncCallable.function(String name, String arguments,
FutureOr<Value> callback(List<Value> arguments)) =>
AsyncBuiltInCallable.function(name, arguments, callback);
}