Skip to content

Yshayy/falcor.net

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Falcor.NET Build status NuGet package version Coverity Gitter

What is Falcor?

Falcor is an approach pioneered by Netflix that enables you to quickly build a data-driven APIs that deliver efficient payloads to a variety of client form factors, and is able to adapt quickly to changing data access patterns as your application evolves.

Falcor provides many of the benefits of both REST and RPC, while addressing shortcomings these approaches face when building modern web applications.

Release Status: Developer Preview

Falcor.NET will remain in developer preview until a stable client and server reference version is released from Netflix all baseline functionality is implemented. Follow progress on this GitHub issue: falcordotnet#1

Getting Started

To get started with Falcor.NET, follow these steps:

  1. In your ASP.NET web project, install the Falcor.Server.Owin NuGet package:

    PM> Install-Package Falcor.Server.Owin -Pre
    
  2. Create your application router to match paths to a virtual JSON Graph model:

    public class HelloWorldRouter : FalcorRouter
    {
        public HelloWorldRouter()
        {
            // Route to match a JSON path, in this case the 'message' member 
            // of the root JSON node of the virtual JSON Graph
            Get["message"] = async _ =>
            {
                var result = await Task.FromResult(Path("hello"message").Atom("Hello World"));
                return Complete(result);
            };
            // Define additional routes for your virtual model here
        }
    }

    Note: For a more realistic example router, see the example Netflix router which is part of Falcor.Examples.Netflix.Web project that you can run yourself to see the router in action.

  3. In your OWIN startup class, configure your Falcor.NET router endpoint:

    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.UseFalcor("/helloWolrdModel.json", routerFactory: config => new HelloWorldRouter());
            ...
        }
    }
  4. Using falcor.js in your client, create a new Falcor model, specifying the URL of your new endpoint for your datasource:

    var model = new falcor.Model({
        source: new falcor.HttpDataSource('/helloWorldModel.json')
    });
  5. You've done all you need to talk to your router, call your model like so:

    model.get('message').then(function(json) {
        console.log(json);
    });

// Result: { json: { message: "Hello World!" } }


<h1 id="uses">When To Use Falcor</h1>
**_Consider the Falcor approach when you are developing a client/server architecture that is intended to provide a rich client user experience._** 

| *Good Fit*                                                                                     | *Poor Fit*                                                                        |
|------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| Fetching _large amounts_ of _small resources_ (e.g. web components, JSON, metadata, etc.)      | Fetching _small amounts_ of _large resources_ (e.g. web pages, images, files, etc.) |
| Aggregating heterogeneous services efficiently (e.g. microservices or loosley-coupled modules) | Speaking to a single back-end data source or service provider                   |
| Delivering responsive and capable end-user client experiences                                  | Systems integration and public APIs; static websites                            |
| Heterogeneous and evolving data access patterns (multiple devices, changing use cases)         |                                                                                 |


# License
Apache 2.0

About

.NET Falcor router for efficient data fetching

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 91.2%
  • F# 8.0%
  • Batchfile 0.8%