Skip to content
This repository was archived by the owner on Jun 3, 2022. It is now read-only.

Commit 496f7ca

Browse files
author
Andres Ugarte
committed
Remove convenience initializers and add documentaion
1 parent 4e46895 commit 496f7ca

File tree

9 files changed

+40
-26
lines changed

9 files changed

+40
-26
lines changed

examples/objc/RemixerExample/FontViewController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ - (void)viewDidLoad {
3737

3838
[RMXStringVariable stringVariableWithKey:@"labelText"
3939
defaultValue:@"This is a customizable label"
40+
possibleValues:nil
4041
updateBlock:^(RMXStringVariable *variable, NSString *selectedValue) {
4142
_fontLabel.text = selectedValue;
4243
[self.view setNeedsLayout];

src/core/RMXRemixer.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,14 @@ + (void)start {
8787

8888
#ifdef REMIXER_CLOUD_FIREBASE
8989
instance.remoteController = [[RMXFirebaseRemoteController alloc] init];
90-
[instance.remoteController setup];
9190
[instance.remoteController startObservingUpdates];
9291
#endif
9392
}
9493

9594
+ (void)stop {
96-
// No-op
95+
#ifdef REMIXER_CLOUD_FIREBASE
96+
[[[self sharedInstance] remoteController] stopObservingUpdates];
97+
#endif
9798
}
9899

99100
+ (NSString *)sessionId {

src/core/remixes/RMXColorVariable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ typedef void (^RMXColorUpdateBlock)(RMXColorVariable *variable, UIColor *selecte
3636
/** Designated initializer. */
3737
+ (instancetype)colorVariableWithKey:(NSString *)key
3838
defaultValue:(UIColor *)defaultValue
39-
possibleValues:(NSArray<UIColor *> *)possibleValues
39+
possibleValues:(nullable NSArray<UIColor *> *)possibleValues
4040
updateBlock:(RMXColorUpdateBlock)updateBlock;
4141

4242
@end

src/core/remixes/RMXNumberVariable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ typedef void (^RMXNumberUpdateBlock)(RMXNumberVariable *variable, CGFloat select
3737
/** Designated initializer. */
3838
+ (instancetype)numberVariableWithKey:(NSString *)key
3939
defaultValue:(CGFloat)defaultValue
40-
possibleValues:(NSArray<NSNumber *> *)possibleValues
40+
possibleValues:(nullable NSArray<NSNumber *> *)possibleValues
4141
updateBlock:(RMXNumberUpdateBlock)updateBlock;
4242

4343
@end

src/core/remixes/RMXStringVariable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typedef void (^RMXStringUpdateBlock)(RMXStringVariable *variable, NSString *sele
3434
/** Designated initializer. */
3535
+ (instancetype)stringVariableWithKey:(NSString *)key
3636
defaultValue:(NSString *)defaultValue
37-
possibleValues:(NSArray<NSString *> *)possibleValues
37+
possibleValues:(nullable NSArray<NSString *> *)possibleValues
3838
updateBlock:(RMXStringUpdateBlock)updateBlock;
3939

4040
@end

src/core/remote/RMXFirebaseRemoteController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
@class RMXVariable;
2121

22+
/** A Firebase implementation of Remote Controllers. */
2223
@interface RMXFirebaseRemoteController : NSObject<RMXRemoteController>
2324

2425
@end

src/core/remote/RMXFirebaseRemoteController.m

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
#import "RMXRemixer.h"
2626

2727
static NSString *const kFirebasePath = @"Remixer";
28-
static NSString *const kFirebaseDeviceKey = @"device_id";
2928

3029
@implementation RMXFirebaseRemoteController {
30+
NSString *_deviceKey;
3131
FIRDatabaseReference *_ref;
3232
NSMutableDictionary<NSString *, RMXVariable *> *_storedVariables;
3333
}
@@ -41,14 +41,13 @@ + (instancetype)sharedInstance {
4141
return sharedInstance;
4242
}
4343

44-
- (void)setup {
44+
- (void)startObservingUpdates {
45+
_deviceKey = [[[NSUUID UUID] UUIDString] substringToIndex:8];
4546
[FIRApp configure];
4647
_ref = [[FIRDatabase database] referenceWithPath:kFirebasePath];
4748
_storedVariables = [NSMutableDictionary dictionary];
48-
}
4949

50-
- (void)startObservingUpdates {
51-
[[_ref child:kFirebaseDeviceKey]
50+
[[_ref child:_deviceKey]
5251
observeEventType:FIRDataEventTypeChildChanged
5352
withBlock:^(FIRDataSnapshot *_Nonnull snapshot) {
5453
NSDictionary *jsonDictionary = snapshot.value;
@@ -61,27 +60,23 @@ - (void)startObservingUpdates {
6160
}
6261

6362
- (void)stopObservingUpdates {
64-
[[_ref child:kFirebaseDeviceKey] removeAllObservers];
65-
}
66-
67-
- (void)shutDown {
68-
// No-op.
63+
[[_ref child:_deviceKey] removeAllObservers];
6964
}
7065

7166
- (void)addVariable:(RMXVariable *)variable {
72-
[[[_ref child:kFirebaseDeviceKey] child:variable.key] setValue:[variable toJSON]];
67+
[[[_ref child:_deviceKey] child:variable.key] setValue:[variable toJSON]];
7368
}
7469

7570
- (void)updateVariable:(RMXVariable *)variable {
76-
[[[_ref child:kFirebaseDeviceKey] child:variable.key] setValue:[variable toJSON]];
71+
[[[_ref child:_deviceKey] child:variable.key] setValue:[variable toJSON]];
7772
}
7873

7974
- (void)removeVariable:(RMXVariable *)variable {
80-
[[[_ref child:kFirebaseDeviceKey] child:variable.key] removeValue];
75+
[[[_ref child:_deviceKey] child:variable.key] removeValue];
8176
}
8277

8378
- (void)removeAllVariables {
84-
[[_ref child:kFirebaseDeviceKey] removeValue];
79+
[[_ref child:_deviceKey] removeValue];
8580
}
8681

8782
@end

src/core/remote/RMXRemoteController.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,28 @@
1818

1919
NS_ASSUME_NONNULL_BEGIN
2020

21-
/** */
21+
/** Interface for the different types of remote controllers supported by Remixer */
2222
@protocol RMXRemoteController <NSObject>
2323

2424
@required
2525

26+
/** Called when Remixer is ready to start receiving updates from remote controllers */
27+
- (void)startObservingUpdates;
28+
29+
/** Called when Remixer wants to stop receiving updates from remote controllers */
30+
- (void)stopObservingUpdates;
31+
32+
/** Adds a variable to the remote controllers */
2633
- (void)addVariable:(RMXVariable *)variable;
34+
35+
/** Updates a variable in the remote controllers */
2736
- (void)updateVariable:(RMXVariable *)variable;
37+
38+
/** Removes a variable from the remote controllers */
2839
- (void)removeVariable:(RMXVariable *)variable;
29-
- (void)removeAllVariables;
3040

31-
- (void)setup;
32-
- (void)startObservingUpdates;
33-
- (void)stopObservingUpdates;
34-
- (void)shutDown;
41+
/** Removes all variables from the remote controllers */
42+
- (void)removeAllVariables;
3543

3644
@end
3745

src/core/storage/RMXStorageController.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,21 @@
1818

1919
NS_ASSUME_NONNULL_BEGIN
2020

21-
/** Interface for they different types of storage supported by Remixer. */
21+
/** Interface for the different types of storage options supported by Remixer. */
2222
@protocol RMXStorageController <NSObject>
2323

2424
@required
2525

26+
/**
27+
Retrieves the saved value for a variable's key
28+
@param key The variable's key
29+
*/
2630
- (nullable id)selectedValueForVariableKey:(NSString *)key;
2731

32+
/**
33+
Saves the selected value of the variable
34+
@param variable The variable whos selected value we want to save
35+
*/
2836
- (void)saveSelectedValueOfVariable:(RMXVariable *)variable;
2937

3038
@end

0 commit comments

Comments
 (0)