Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

examples/push: fix constructor syntax #50

Merged
merged 1 commit into from
Jan 30, 2016
Merged
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
4 changes: 2 additions & 2 deletions examples/FirebasePush_ESP8266/FirebasePush_ESP8266.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <Firebase.h>

// create firebase client.
Firebase fbase("example.firebaseio.com")
.auth("secret_or_token");
Firebase fbase = Firebase("example.firebaseio.com")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax is odd for c++. You are basically telling the compiler to create a empty Firebase object "fbase" then copy another anonymous Firebase object into it. So two objects + copy constructor. Copy elision should optimize this away but depending on a compiler optimization looks odd to c++ eyes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I just restored the example the way it was before.

I think moving forward we should embrace two-step initialization, which seems to be a common pattern in Arduino-land.

Firebase fbase;

void setup() {
 fbase.begin("host", "auth");
}

WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a little more combersome but I can see how it is useful with the setup() loop() cycle. We could provide both options.

How about we call it "setup()" instead of begin though. to match the arduino function name.

.auth("secret_or_token");

void setup() {
Serial.begin(9600);
Expand Down