jeudi 29 septembre 2016

What is the name of this design pattern using Performer?

What is the name of the pattern that used Retrofit 2.0 and some other libraries?

The old version

some manager can load data sync and async by two different methods

SomeClass obj = someManager.getDataSync();
SomeClass2 obj = otherManager.getBigDataSync()
SomeClass3 obj = otherManager2.getMyDataSync()

or

someManager.loadData(callback)
otherManager.loadData(callback2)
otherManager2.loadData(callbak3)

Now istead uses a helper class

New version

Performer<T> performer = someManager.getSomeData(...);

then we can execute this action sync or asyc with listener

T data = performer.performSync();

or

performer.performAsync(callback);

Aucun commentaire:

Enregistrer un commentaire