
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Firebase REST API wrapper with streaming API wired with MVVM observers.
NuGets
Name | Info |
---|---|
RestfulFirebase |
// Install release version
Install-Package RestfulFirebase
// Install pre-release version
Install-Package RestfulFirebase -pre
.NET Standard 2.0 - see https://github.com/dotnet/standard/blob/master/docs/versions.md for compatibility matrix
using RestfulFirebase;
namespace YourNamespace
{
public static class Program
{
private static FirebaseConfig config;
private static RestfulFirebaseApp app;
public static void Main(string[] args)
{
config = new FirebaseConfig("<Your project ID>", "<Your API key>")
{
LocalDatabase = "<Your implementation of RestfulFirebase.Local.ILocalDatabase>" // For optional offline persistency
};
app = new RestfulFirebaseApp(config);
}
}
}
using RestfulFirebase;
namespace YourNamespace
{
public static class Program
{
public static async void Authenticate()
{
await app.Auth.SignInWithEmailAndPassword("t@st.com", "123123");
}
}
}
The RealtimeWire holds a database subscription for real-time online and local data updates; Also manages offline persistency and caching for the specified reference node. Persistent data from the app launch will continue to sync if its real-time node or its parent`s real-time node is created and started.
using RestfulFirebase.RealtimeDatabase.Models;
namespace YourNamespace
{
public class Dinosaur : FirebaseObject
{
public string Name
{
get => GetFirebasePropertyWithKey("name", () => "Default name");
set => SetFirebasePropertyWithKey(value, "name");
}
public string? Family
{
get => GetFirebasePropertyWithKey<string>("family");
set => SetFirebasePropertyWithKey(value, "family");
}
// Uses its property name for firebase key.
public int Height
{
get => GetFirebaseProperty<int>();
set => SetFirebaseProperty(value);
}
}
}
Predefined model values will be overwritten by the database values.
using System.Threading.Tasks;
using RestfulFirebase;
using RestfulFirebase.RealtimeDatabase.Realtime;
namespace YourNamespace
{
public static class Program
{
public static void Subscribe()
{
// Creates new realtime wire for https://some-database.firebaseio.com/users/some-uid/pets/dinosaur
RealtimeWire userWire = app.RealtimeDatabase
.Database("<Your realtime database URL (i.e https://some-database.firebase.io)>")
.Child("users")
.Child(app.Auth.Session.LocalId) // User UID
.Child("pets")
.Child("dinosaur")
.AsRealtimeWire();
// Starts to subscribe and listen for the node`s local and online updates
// Realtime local data persistency and notification starts with this node.
userWire.Start();
// Create models
Dinosaur dinosaur1 = new Dinosaur();
Dinosaur dinosaur2 = new Dinosaur();
// Subscribes model to the node https://some-database.firebaseio.com/users/some-uid/pets/dinosaur/dino1
userWire.Child("dino1").PutModel(dinosaur1);
// Subscribes model to the node https://some-database.firebaseio.com/users/some-uid/pets/dinosaur/dino2
userWire.Child("dino2").PutModel(dinosaur2);
// "dinosaur1" and "dinosaur1" are now subscribed to each node`s local and online changes.
// Any preceding changes to "Dinosaur.Name" property will reflect in its database node and vice-versa.
// Changes will trigger the model`s INotifyPropertyChanged observers.
}
}
}
Database values will be overwritten by the predefined model values.
using System.Threading.Tasks;
using RestfulFirebase;
using RestfulFirebase.RealtimeDatabase.Realtime;
namespace YourNamespace
{
public static class Program
{
public static void WriteAndSubscribe()
{
// Creates new realtime wire for https://some-database.firebaseio.com/users/some-uid/pets/dinosaur
RealtimeWire userWire = app.RealtimeDatabase
.Database("<Your realtime database URL (i.e https://some-database.firebase.io)>")
.Child("users")
.Child(app.Auth.Session.LocalId) // User UID
.Child("pets")
.Child("dinosaur")
.AsRealtimeWire();
// Starts to subscribe and listen for the node`s local and online updates.
// Realtime local data persistency and notification starts with this node.
userWire.Start();
// Create models
Dinosaur dinosaur1 = new Dinosaur();
Dinosaur dinosaur2 = new Dinosaur();
dinosaur1.Name = "Megalosaurus";
dinosaur2.Name = "T-rex";
// Write and subscribes model to the node https://some-database.firebaseio.com/users/some-uid/pets/dinosaur/dino1
userWire.Child("dino1").PutModel(dinosaur1);
// Write and subscribes model to the node https://some-database.firebaseio.com/users/some-uid/pets/dinosaur/dino2
userWire.Child("dino2").PutModel(dinosaur2);
// "dinosaur1" and "dinosaur1" are now subscribed to each local and online changes.
// Any preceding changes to "Dinosaur.Name" property will reflect in its database node and vice-versa.
// Changes will trigger the model`s INotifyPropertyChanged observers.
}
}
}
Creating a listen instance of the existing realtime wire without resubscribing to the node will save you some bandwidth and usage.
using System.Threading.Tasks;
using RestfulFirebase;
using RestfulFirebase.RealtimeDatabase.Realtime;
namespace YourNamespace
{
public static class Program
{
public static void WriteAndSubscribe()
{
// Creates new realtime wire for https://some-database.firebaseio.com/users/some-uid/
RealtimeWire userWire = app.RealtimeDatabase
.Database("<Your realtime database URL (i.e https://some-database.firebase.io)>")
.Child("users")
.Child(app.Auth.Session.LocalId) // User UID
.AsRealtimeWire();
// Starts to subscribe and listen for the node`s local and online updates
userWire.Start();
// Creates a new listen instance without resubscribing to the node.
RealtimeInstance userDinosaur = userWire
.Child("pets")
.Child("dinosaur");
RealtimeInstance userDinosaur1 = userWire
.Child("pets")
.Child("dinosaur1");
RealtimeInstance userDinosaur2 = userWire
.Child("pets")
.Child("dinosaur2");
}
}
}
using RestfulFirebase.RealtimeDatabase.Models;
namespace YourNamespace
{
public static class Program
{
private static Dinosaur dinosaur;
public static void UIThread()
{
dinosaur = new Dinosaur();
}
public static void BackgroundThread()
{
// Subscribe to both online and local updates
dinosaur.PropertyChanged += (s, e) =>
{
// Executed on current thread
}
dinosaur.SynchronizedPropertyChanged += (s, e) =>
{
// Executed on UI thread
}
dinosaur.Name = "Megalosaurus";
}
}
}
Code & Inspiration from the following:
All I have ever asked is to be active by submitting bugs, features, and sending those pull requests down!.
FAQs
Firebase REST API wrapper wired with MVVM observables.
We found that restfulfirebase demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.