Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

observerevent event type issue fixed #2

Merged
merged 4 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Use the native Firebase SDK in Axway Titanium. This repository is part of the [T

- `root(arguments)` -> `FirebaseDatabaseReference`
 - `observableEvents` ([`DATA_EVENT_TYPE_*`])

- `parent(arguments)` -> `FirebaseDatabaseReference`
- `observableEvents` ([`DATA_EVENT_TYPE_*`])

Expand All @@ -39,7 +39,7 @@ Use the native Firebase SDK in Axway Titanium. This repository is part of the [T

- `removeValue(callback)`
 - `callback` (optional, Function)

- `updateChildValues(childValues, callback)`
 - `childValues` (Dictionary)
 - `callback` (optional, Function)
Expand All @@ -64,21 +64,21 @@ Use the native Firebase SDK in Axway Titanium. This repository is part of the [T
#### Constants

- `DATA_EVENT_TYPE_VALUE`
- `DATA_EVENT_TYPE_ADD`
- `DATA_EVENT_TYPE_CHANGE`
- `DATA_EVENT_TYPE_MOVE`
- `DATA_EVENT_TYPE_REMOVE`
- `DATA_EVENT_TYPE_CHILD_ADDED`
- `DATA_EVENT_TYPE_CHILD_CHANGED`
- `DATA_EVENT_TYPE_CHILD_MOVED`
- `DATA_EVENT_TYPE_CHILD_REMOVED`

## Events

Important note: Events are added and removed generically. They are only fired if you observe them via
the `observableEvents` parameter.

- `value` (via `DATA_EVENT_TYPE_VALUE`)
- `add` (via `DATA_EVENT_TYPE_ADD`)
- `change` (via `DATA_EVENT_TYPE_CHANGE`)
- `move` (via `DATA_EVENT_TYPE_MOVE`)
- `remove` (via `DATA_EVENT_TYPE_REMOVE`)
- `add` (via `DATA_EVENT_TYPE_CHILD_ADDED`)
- `change` (via `DATA_EVENT_TYPE_CHILD_CHANGED`)
- `move` (via `DATA_EVENT_TYPE_CHILD_MOVED`)
- `remove` (via `DATA_EVENT_TYPE_CHILD_REMOVED`)

## Example
```js
Expand Down
6 changes: 6 additions & 0 deletions ios/Classes/FirebaseDatabaseModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ @implementation FirebaseDatabaseModule

#pragma mark Internal

MAKE_SYSTEM_PROP(DATA_EVENT_TYPE_VALUE, FIRDataEventTypeValue);
MAKE_SYSTEM_PROP(DATA_EVENT_TYPE_CHILD_ADDED, FIRDataEventTypeChildAdded);
MAKE_SYSTEM_PROP(DATA_EVENT_TYPE_CHILD_REMOVED, FIRDataEventTypeChildRemoved);
MAKE_SYSTEM_PROP(DATA_EVENT_TYPE_CHILD_MOVED, FIRDataEventTypeChildMoved);
MAKE_SYSTEM_PROP(DATA_EVENT_TYPE_CHILD_CHANGED, FIRDataEventTypeChildChanged);

- (id)moduleGUID
{
return @"70e51a34-9140-4f84-bc9b-59960d99fbf8";
Expand Down
28 changes: 11 additions & 17 deletions ios/Classes/FirebaseDatabaseReferenceProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ - (FirebaseDatabaseReferenceProxy *)child:(id)arguments
- (FirebaseDatabaseReferenceProxy *)parent:(id)arguments
{
ENSURE_SINGLE_ARG(arguments, NSDictionary);

NSArray *observableEvents = [arguments objectForKey:@"observableEvents"];

return [[FirebaseDatabaseReferenceProxy alloc] _initWithPageContext:self.pageContext
andDatabaseReference:[self _referenceFromArguments:arguments andType:TiReferenceTypeParent]
observableEvents:observableEvents];
Expand All @@ -71,9 +71,9 @@ - (FirebaseDatabaseReferenceProxy *)parent:(id)arguments
- (FirebaseDatabaseReferenceProxy *)root:(id)arguments
{
ENSURE_SINGLE_ARG(arguments, NSDictionary);

NSArray *observableEvents = [arguments objectForKey:@"observableEvents"];

return [[FirebaseDatabaseReferenceProxy alloc] _initWithPageContext:self.pageContext
andDatabaseReference:[self _referenceFromArguments:arguments andType:TiReferenceTypeRoot]
observableEvents:observableEvents];
Expand Down Expand Up @@ -196,29 +196,29 @@ - (FIRDatabaseReference *)_referenceFromArguments:(NSDictionary *)arguments andT
if (type == TiReferenceTypeRoot) {
return [_reference root];
}

if (type == TiReferenceTypeParent) {
return [_reference parent];
}

NSString *identifier = [arguments objectForKey:@"identifier"];
NSString *path = [arguments objectForKey:@"path"];
NSString *url = [arguments objectForKey:@"url"];

FIRDatabaseReference *reference = nil;

if (identifier != nil) {
return [[[FIRDatabase database] reference] child:identifier];
}

if (path != nil) {
return [[FIRDatabase database] referenceWithPath:path];
}

if (url != nil) {
return [[FIRDatabase database] referenceFromURL:url];
}

[self throwException:@"Cannot construct database reference"
subreason:@"No valid key (identifier, path or url) found"
location:CODELOCATION];
Expand Down Expand Up @@ -247,10 +247,4 @@ - (void)_sendEvent:(NSDictionary *)event forEventType:(FIRDataEventType)eventTyp
[self fireEvent:identifier withObject:event];
}

MAKE_SYSTEM_PROP(DATA_EVENT_TYPE_VALUE, FIRDataEventTypeChildAdded);
MAKE_SYSTEM_PROP(DATA_EVENT_TYPE_ADD, FIRDataEventTypeChildAdded);
MAKE_SYSTEM_PROP(DATA_EVENT_TYPE_REMOVE, FIRDataEventTypeChildRemoved);
MAKE_SYSTEM_PROP(DATA_EVENT_TYPE_MOVE, FIRDataEventTypeChildMoved);
MAKE_SYSTEM_PROP(DATA_EVENT_TYPE_CHANGE, FIRDataEventTypeChildChanged);

@end
4 changes: 2 additions & 2 deletions ios/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 1.1.0
version: 1.1.1
apiversion: 2
architectures: armv7 arm64 i386 x86_64
description: titanium-firebase-database
Expand All @@ -15,4 +15,4 @@ name: titanium-firebase-database
moduleid: firebase.database
guid: 70e51a34-9140-4f84-bc9b-59960d99fbf8
platform: iphone
minsdk: 6.3.0.GA
minsdk: 6.3.0.GA
4 changes: 2 additions & 2 deletions ios/titanium.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
// OF YOUR TITANIUM SDK YOU'RE BUILDING FOR
//
//
TITANIUM_SDK_VERSION = 7.0.1.GA
TITANIUM_SDK_VERSION = 7.1.1.GA

//
// THESE SHOULD BE OK GENERALLY AS-IS
//
TITANIUM_SDK = /Users/hknoechel/Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA
TITANIUM_SDK = ~/Library/Application Support/Titanium/mobilesdk/osx/$(TITANIUM_SDK_VERSION)
TITANIUM_BASE_SDK = "$(TITANIUM_SDK)/iphone/include"
TITANIUM_BASE_SDK2 = "$(TITANIUM_SDK)/iphone/include/TiCore"
TITANIUM_BASE_SDK3 = "$(TITANIUM_SDK)/iphone/include/JavaScriptCore"
Expand Down