Make parseId static + docs
This commit is contained in:
parent
d211804cd8
commit
2a306e1ec3
2 changed files with 9 additions and 2 deletions
|
@ -12,3 +12,6 @@
|
||||||
* Moved `TypedService` into `package:angel_typed_service`.
|
* Moved `TypedService` into `package:angel_typed_service`.
|
||||||
* Completely removed the `AngelBase` class.
|
* Completely removed the `AngelBase` class.
|
||||||
* Removed all `@deprecated` symbols.
|
* Removed all `@deprecated` symbols.
|
||||||
|
* `Service.toId` was renamed to `Service.parseId`; it also now uses its
|
||||||
|
single type argument to determine how to parse a value.
|
||||||
|
* In addition, this method was also made `static`.
|
|
@ -124,7 +124,11 @@ class Service extends Routable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transforms an [id] (whether it is a String, num, etc.) into one acceptable by a service.
|
/// Transforms an [id] (whether it is a String, num, etc.) into one acceptable by a service.
|
||||||
T parseId<T>(id) {
|
///
|
||||||
|
/// The single type argument, [T], is used to determine how to parse the [id].
|
||||||
|
///
|
||||||
|
/// For example, `parseId<bool>` attempts to parse the value as a [bool].
|
||||||
|
static T parseId<T>(id) {
|
||||||
if (id == 'null' || id == null)
|
if (id == 'null' || id == null)
|
||||||
return null;
|
return null;
|
||||||
else if (T == String)
|
else if (T == String)
|
||||||
|
|
Loading…
Reference in a new issue