YMBaseViewModel.m 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // YMBaseViewModel.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/4.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMBaseViewModel.h"
  9. @interface YMBaseViewModel()
  10. /// 参数
  11. @property (nonatomic, copy, readwrite) NSDictionary *params;
  12. /// 刷新UI
  13. @property (nonatomic, strong, readwrite) RACSubject *refreshUISubject;
  14. @end
  15. @implementation YMBaseViewModel
  16. + (instancetype)allocWithZone:(struct _NSZone *)zone {
  17. YMBaseViewModel *viewModel = [super allocWithZone:zone];
  18. @weakify(viewModel)
  19. [[viewModel rac_signalForSelector:@selector(initWithParams:)] subscribeNext:^(id x) {
  20. @strongify(viewModel)
  21. [viewModel ym_initialize];
  22. }];
  23. return viewModel;
  24. }
  25. - (instancetype)initWithParams:(NSDictionary *)params {
  26. if (self = [super init]) {
  27. self.params = params;
  28. }
  29. return self;
  30. }
  31. - (void)ym_initialize {
  32. }
  33. - (RACSubject *)refreshUISubject {
  34. if (!_refreshUISubject) {
  35. _refreshUISubject = [RACSubject subject];
  36. }
  37. return _refreshUISubject;
  38. }
  39. @end