Skip to content

adcmdev/fkafka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Have you ever wanted to send a message to another part of the app but don't want to create a direct connection? This package allows you to send and listen topic anywhere. Can connect to any topic in anywhere and get data without direct direction.

Features

  • Emit topic and send data.
  • Listen topic and recieve data.
  • Close topic listen.
  • ReOpen connection when is already closed.

Getting started

# Flutter projects
flutter pub get fkafka

# Dart projects
dart pub get fkafka

or add the package directly in the pubspec.yaml

dependencies:
  fkafka: ^1.0.0

Usage

import 'package:fkafka/fkafka.dart';

final kafka = Fkafka();

Emit

kafka.emit(
  topic,
  TopicData(
    action: FkafkaAction.created,
    data: {
      'foo': 'bar'
    },
  ),
);

FkafkaAction {
  created,
  edited,
  deleted,
  changed,
}

Listen

To listen a specific topic you need to create a Fkafka instance.

final kafka = Fkafka();

kafka.listen(
  topic: TulTopics.cart,
  onTopic: (TopicData topic) {
    print(topic);
  },
);

Don't forget to close the instance if it's not going to be used anymore. This will cancel all the subscriptions added to that instance.

kafka.closeInstance();

Close Fkafka

This method should be called if Fkafka won't be used anymore in the code, to avoid having open streams or memory leaks.

Fkafka.closeAll();

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages