Giter Site home page Giter Site logo

raven.net's Introduction

Raven.NET

Hello, this page is about the Raven.NET framework which is an implementation of the observer pattern with several extensions that can be used for a variety of benefits. The name is not accidental and is intended, more precisely described as the last paragraph of this page. If you have suggestions for development, please contact us or create an issue and mark it with correct label.

Build Status Download Count

Installation

To make use of Raven.NET library and its most important features you need to install Core nuget package, you can do this with dotnet command like this:

dotnet add package Raven.NET.Core

or via nuget package manager console:

Install-Package Raven.NET.Core

(feel free to checkout Analytics package as well)

To check newest updates and additional information please check direct link: https://www.nuget.org/packages/Raven.NET.Core

Getting started

To use Raven.NET first step is to register necesary dependencies in service collection, its possible to do this manually (it will be described in details in docs) but there is already extension method prepared for this that you should call in your ConfigureServices method. Example with IHostedService below.

 var host = Host.CreateDefaultBuilder()
        .ConfigureServices((_, services) =>
        {
            services.ConfigureRaven(configuration);
        }).Build();

Then to make use of the most simple observer you should inject IRavenWatcher interface. With this you can create new watchers by using Create method. It needs 2 parameters, when first is name of watcher (needs to be unique) and the second is the callback where we will get updates. Additionally it can have the third parameter which is options, if not provided it will load options from appsettings and if those do not exist then it will use the default configuration. Example of usage is shown below:

var watcher1 = _ravenWatcher1.Create("Raven1", PhoneUpdated, (options) => { options.AutoDestroy = true; });

After our watcher is created then we can tell him to watch a certain object.

watcher1.Watch(testPhone2).Watch(testPhone3);

With this code after we will make changes to watched objects and notify observers about it, we get a message in our callback

testPhone2.Price = 420;
testPhone2.TryNotify();

And we get in our console logged:

image

Raven Type Watcher

In addition we have an implementation for watcher that allows you to watch all objects of a given type automatically and checks for updates, this may be really useful when you don't have strict control over objects in your system (you want to check for updates in lots of objects that you get form database, or load any other different way to your application). The implementation looks similar but has some core differences. And for this case, you need to inject IRavenTypeWatcher

Creation looks similar, the difference is that you need to provide type as a generic parameter and an additionally key that is unique for objects of this type.

_ravenTypeWatcher.Create<Car>("RavenTypeWatcherExample", nameof(Console.Car.Id), Callback);

That is basically it, and now when you will have new object with same id, it will be considered as update (if its different)

 var Car = new Car(1231, "Qudi", "Q2", 40000);
        
 var Car2 = new Car(1231, "Qudi", "Q2", 43000);

image

Docs

Feel free to check out more detailed documentation, as good start we propose taking look on the introduction page

Introduction

Why the name raven?

Some time ago I watched a series in which a raven was an animal that was used for observation. It starred at the target carefully as if it wanted to see all the details and potential clues. For those interested, there were also vampires and werewolves in the series (probably many of you already guess what the series is about). I recently remembered this and read a bit about it, even found out that ravens are considered animals that can be tracked by military and governmental organizations. Hence the idea to name the library whose core will be based on the observer pattern as Raven. An additional advantage of this approach is an easy understanding of the context and purpose, I would like this library to be able to describe what it does, and this approach is also evident in the interfaces and approaches to using the framework. I believe that by basing the elements of logic that are visible in the code on elements that are visible in the natural environment, the principles of operation should be easier to understand

raven.net's People

Contributors

cebulmaciej avatar pswierad avatar pswierad-src avatar wisedev-pstach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

wisedev-pstach

raven.net's Issues

Establishing best approach to logging

We should have a talk about how much and how in depth logging we want to have. We should find balance between being descriptive enough and not cluttering code with extensive logging.

Setup pipeline

Goal is to create github actions for building and pubishing nuget package (best way is to have available to prelease version if possible) additionaly i would like to have step for running unit tests (which are not there yet, but we will implement those for sure)

Find better way to have value cached for ravens and subjects

For now we have memory cache (dictionaries) but its widly used directly withing system by calling static class, we should thing of something better, problem is that its also used by entity classes like RavenSubject to check for their previous state, those classes does not have dependency injection, so injecting abstraction is much more difficult for it, thats why we use static class because its easy accesible within system

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.