Full name property automatically freshes the UI bound to this property when firstName or lastName changes.
Validation
@ValidatepublicgeterrorFirstName(){returnthis.model.firstName?"":"First name is required";}
Validate decorator helps in setting up validation that updates UI automatically when property is changed.
AJAX Services
@DISingleton()@BaseUrl("/api/v2020/app/")exportdefaultclassTaskServiceextendsBaseService{@Get("user")publicgetUser():Promise<IUser>;@Get("tasks")publicgetTasks(@Query("search")search:string,// default value should be specified in// decorator and not in argument declaration@Query("status","open")status?:string):Promise<ITask[]>@Get("tasks/{id}/attachments")publicgetAttachments(@Path("id")id:number):Promise<ITaskAttachment[]>;@Put("tasks")publiccreateTask(@Bodytask:ITask):Promise<ITask>;@Post("tasks/{id}/attachments")publicuploadAttachment(@Path("id")id:number,@Bodyatt:IAttachment,cancelToken:CancelToken):Promise<void>;}
Data Loading
This is a bit complex, it handles loading of data and canceling previous request automatically.
At Web Atoms, we are using decorator as follow,
Bindable Property
This turns member into property with getter/setter with ability to refresh the UI whenever it is set.
Dependency Injection
DI container automatically injects service for specified type.
Watch Decorator
Full name property automatically freshes the UI bound to this property when firstName or lastName changes.
Validation
Validate decorator helps in setting up validation that updates UI automatically when property is changed.
AJAX Services
Data Loading
This is a bit complex, it handles loading of data and canceling previous request automatically.
So whenever
search
is updated, this method is called automatically and UI refreshes it, it discards (aborts) previous ongoing request.For more information...
RetroFit inspired REST Services in Web Atoms Core
Akash Kava ・ Jul 5 '19 ・ 2 min read
ViewModel Decorators in Web Atoms for Xamarin.Forms
Akash Kava ・ Jun 14 ・ 2 min read
Simple and Complex Data Validation in Web Atoms
Akash Kava ・ Aug 28 '19 ・ 4 min read
Interesting implementations, Akash!