RxSwiftCommunity / RxFirebase

RxSwift extensions for Firebase
MIT License
224 stars 66 forks source link

Add Auth Examples #7

Closed TaeJoongYoon closed 5 years ago

TaeJoongYoon commented 5 years ago

Add examples to README about Auth

TaeJoongYoon commented 5 years ago

Oh, I'm sorry.

In updateEmail and delete, Must replace let auth = Auth.auth() with let auth = Auth.auth().currentUser?

arnauddorgans commented 5 years ago

Absolutely, delete and updateEmail are a reactive User extension, not an Auth extension

TaeJoongYoon commented 5 years ago

You're right.

Then can I split them?

arnauddorgans commented 5 years ago

What do you mean ? @TaeJoongYoon

TaeJoongYoon commented 5 years ago

Auth

Create:

 let auth = Auth.auth()

 // Create a password-based account
 auth.rx.createUser(withEmail: "xxx@xxx.com", password: "1q2w3e4r")
     .subscribe(onNext: { authResult in
         // User signed in
     }, onError: { error in
         // Uh-oh, an error occurred!
     }).disposed(by: disposeBag)
  // https://firebase.google.com/docs/auth/ios/password-auth

Sign In:

 let auth = Auth.auth()

 // Sign in a user with an email address and password
 auth.rx.signIn(withEmail: "xxx@xxx.com", password: "1q2w3e4r")
     .subscribe(onNext: { authResult in
         // User signed in
     }, onError: { error in
         // Uh-oh, an error occurred!
     }).disposed(by: disposeBag)
  // https://firebase.google.com/docs/auth/ios/password-auth

User

Update Email:

 let auth = Auth.auth().currentUser?

 // Set a user's email address
 auth.rx.updateEmail(to: "xxx@xxx.com")
     .subscribe(onNext: {
         // Completed updating Email
     }, onError: { error in
         // Uh-oh, an error occurred!
     }).disposed(by: disposeBag)
  // https://firebase.google.com/docs/auth/ios/manage-users

Delete:

 let auth = Auth.auth().currentUser?

 // Delete a user
 auth.rx.delete()
     .subscribe(onNext: {
         // User deleted
     }, onError: { error in
         // Uh-oh, an error occurred!
     }).disposed(by: disposeBag)
  // https://firebase.google.com/docs/auth/ios/manage-users

I mean like this.

arnauddorgans commented 5 years ago

Yes ! maybe replace the wording "auth" with "user" for email address & delete overwise it's perfect

TaeJoongYoon commented 5 years ago

Yes :) I edit it.

arnauddorgans commented 5 years ago

you have to replace auth.rx.updateEmail => user.rx.updateEmail and auth.rx.delete() => user.rx.delete()

TaeJoongYoon commented 5 years ago

I'm so sorry... I replace them

arnauddorgans commented 5 years ago

perfect! thx for your help :)