refactor(@desktop/wallet): Add eventemitter

This commit is contained in:
Anthony Laibe 2021-10-19 09:38:35 +02:00 committed by Iuri Matias
parent 072b36e672
commit 5d523b739e
8 changed files with 41 additions and 16 deletions

View File

@ -69,7 +69,12 @@ proc newModule*[T](
)
result.walletSectionModule = wallet_section_module.newModule[Module[T]](
result, tokenService, transactionService, collectible_service, walletAccountService
result,
events,
tokenService,
transactionService,
collectible_service,
walletAccountService
)
@ -102,10 +107,11 @@ method load*[T](self: Module[T]) =
for cModule in self.communitySectionsModule.values:
cModule.load()
self.walletSectionModule.load()
let walletSectionItem = initItem("wallet", ChatSectionType.Wallet.int, "Wallet", "",
"wallet", "", 0, 0)
self.view.addItem(chatSectionItem)
self.walletSectionModule.load()
proc checkIfModuleDidLoad [T](self: Module[T]) =

View File

@ -1,3 +1,4 @@
import eventemitter
import ./io_interface, ./view
export io_interface
@ -8,7 +9,7 @@ type
view: View
moduleLoaded: bool
proc newModule*[T](delegate: T): Module[T] =
proc newModule*[T](delegate: T, events: EventEmitter): Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView(result)

View File

@ -1,3 +1,5 @@
import eventemitter
import ./io_interface, ./view
export io_interface
@ -8,7 +10,7 @@ type
view: View
moduleLoaded: bool
proc newModule*[T](delegate: T): Module[T] =
proc newModule*[T](delegate: T, events: EventEmitter): Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView()

View File

@ -1,5 +1,7 @@
import sequtils, sugar
import eventemitter
import ./io_interface, ./view, ./controller, ./item
import ../../../../../app_service/service/token/service as token_service
@ -12,7 +14,7 @@ type
controller: controller.AccessInterface
moduleLoaded: bool
proc newModule*[T](delegate: T, tokenService: token_service.ServiceInterface): Module[T] =
proc newModule*[T](delegate: T, events: EventEmitter, tokenService: token_service.ServiceInterface): Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView(result)

View File

@ -1,9 +1,11 @@
import eventemitter
import ./io_interface, ./view
import ../../../../../app_service/service/collectible/service as collectible_service
import collectible/module as collectible_module
import collections/module as collections_module
import collectibles/module as collectibles_module
import ./collectible/module as collectible_module
import ./collections/module as collections_module
import ./collectibles/module as collectibles_module
export io_interface
@ -19,6 +21,7 @@ type
proc newModule*[T](
delegate: T,
events: EventEmitter,
collectibleService: collectible_service.ServiceInterface
): Module[T] =
result = Module[T]()

View File

@ -1,3 +1,5 @@
import eventemitter
import ./io_interface, ./view
export io_interface
@ -8,7 +10,7 @@ type
view: View
moduleLoaded: bool
proc newModule*[T](delegate: T): Module[T] =
proc newModule*[T](delegate: T, events: EventEmitter): Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView()

View File

@ -1,3 +1,5 @@
import eventemitter
import ./io_interface as io_ingerface
import ./view
@ -32,6 +34,7 @@ type
proc newModule*[T](
delegate: T,
events: EventEmitter,
tokenService: token_service.Service,
transactionService: transaction_service.Service,
collectibleService: collectible_service.Service,
@ -42,12 +45,12 @@ proc newModule*[T](
result.view = newView()
result.moduleLoaded = false
result.accountTokensModule = account_tokens_module.newModule(result)
result.accountsModule = accounts_module.newModule(result)
result.allTokensModule = all_tokens_module.newModule(result, tokenService)
result.collectiblesModule = collectibles_module.newModule(result, collectibleService)
result.mainAccountModule = main_account_module.newModule(result)
result.transactionsModule = transactions_module.newModule(result, transactionService)
result.accountTokensModule = account_tokens_module.newModule(result, events)
result.accountsModule = accounts_module.newModule(result, events)
result.allTokensModule = all_tokens_module.newModule(result, events, tokenService)
result.collectiblesModule = collectibles_module.newModule(result, events, collectibleService)
result.mainAccountModule = main_account_module.newModule(result, events)
result.transactionsModule = transactions_module.newModule(result, events, transactionService)
method delete*[T](self: Module[T]) =
self.accountTokensModule.delete

View File

@ -1,3 +1,5 @@
import eventemitter
import ./io_interface, ./view, ./controller
import ../../../../../app_service/service/transaction/service as transaction_service
@ -10,7 +12,11 @@ type
controller: controller.AccessInterface
moduleLoaded: bool
proc newModule*[T](delegate: T, transactionService: transaction_service.ServiceInterface): Module[T] =
proc newModule*[T](
delegate: T,
events: EventEmitter,
transactionService: transaction_service.ServiceInterface
): Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView(result)