Advertisement
Guest User

Untitled

a guest
May 26th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. UserManager
  2. login
  3. create
  4. authorizeWithFacebook
  5.  
  6. AppSession
  7. user
  8. hostel
  9. accessToken
  10.  
  11. ----
  12.  
  13. EventRepository
  14. findLatest(hostel, offset, callback);
  15. findByID(hostel, eventID, callback);
  16.  
  17. attend(event, user, callback);
  18. decline(event, user, callback);
  19.  
  20. ----
  21.  
  22. HostelRepository
  23. findAll()
  24.  
  25. ----
  26.  
  27. ArticleRepository
  28. findByHostel(hostel)
  29.  
  30. ----
  31.  
  32.  
  33.  
  34. ----
  35.  
  36. PostRepository
  37. findLatest(hostel, offset, callback);
  38.  
  39. like(post, callback);
  40. report(post, callback);
  41.  
  42. createNew(text, image, callback);
  43.  
  44. ----
  45.  
  46. AccountRepository
  47. findByAccessToken(callback)
  48. update(account, callback)
  49.  
  50.  
  51. -----
  52.  
  53. [apiClient GET:@"hostel/checkin" params:@{} callback:^(NSError *error, NSDictionary *response) {
  54. if (error) {
  55. return;
  56. }
  57.  
  58. [self onCheckinStateDetermined:response[@"checkedIn"]];
  59. }];
  60.  
  61.  
  62. ----
  63.  
  64. [[EventViewController alloc] initWithEventID:@"1234"];
  65. [[EventViewController alloc] initWithEvent:event];
  66.  
  67. viewWillAppear: function() {
  68. if (!self.event) {
  69. [EventRepository findByID:self.eventID callback:^(NSError *error, Event *event) {
  70. if (error) {
  71. [self promptError:error];
  72. return;
  73. }
  74.  
  75. [self onEventLoaded:event];
  76. }];
  77. }
  78. else {
  79. [self onEventLoaded:self.event];
  80. }
  81. }
  82.  
  83. ----
  84.  
  85. [[BoardViewController alloc] initWithHostel:hostel]
  86.  
  87. viewWillAppear: function() {
  88. this.refreshPromise = new Promise();
  89.  
  90. [self loadPosts];
  91. }
  92.  
  93. loadPosts: function() {
  94. int x = 0;
  95. [PostRepository findLatest:hostel offset:0 callback:^(NSError *error, NSArray *posts) {
  96. if (error) {
  97. dispatch_after(5s, this.reload);
  98. return;
  99. }
  100.  
  101. [self onPostsReceived:posts];
  102. }];
  103. }
  104.  
  105. onPostsReceived: function() {
  106. self.posts = posts;
  107. }
  108.  
  109. onLoadMore: function() {
  110. if (isLoadingMore) {
  111. return;
  112. }
  113.  
  114. offsetID = [self determineOffsetID];
  115.  
  116. [PostRepository findLatest:hostel offset:[self determineOffsetID] callback:^(NSError *error, NSArray *posts) {
  117. isLoadingMore = false;
  118.  
  119. if (offsetID != [self determineOffsetID]) {
  120.  
  121. return;
  122. }
  123.  
  124. if (error) {
  125. dispatch_after(5s, this.onLoadMore);
  126. return;
  127. }
  128.  
  129. [self.posts mergeWith:newPosts];
  130. }];
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement