v0.5.2Published last year


Timed & localized flash messages for your Meteor app.

Project Status: Active – The project has reached a stable, usable state and is being actively developed. GitHub JavaScript Style Guide Language grade: JavaScript GitHub tag (latest SemVer) All Contributors

Getting started


meteor add freedombase:flashnews



1import { APP_NEWS } from 'freedombase:flashnews'

Constant for the global category of news. When put into objectType of a flashnews it will then be part of the global app news set.


1import { FlashNewsCollection } from 'freedombase:flashnews'

You can import the collection directly like this.


1import { FlashNewsSchema } from 'freedombase:flashnews'

You can import the schema for the collection and use it in your own custom functions for validation or other purposes.


1import { beforeFlashNewsInsert, afterFlashNewsInsert } from 'freedombase:flashnews'

Using meteor/callback-hook, you can set these hooks to be run before and after the provided insert method.

2  userId,
3  content,
4  defaultLanguage,
5  startsAt,
6  endsAt,
7  objectType,
8  objectId,
9  onlyDisplayOn) => {
10  // Here check the user's credentials and return true if to proceed or false if to return unauthorized error
11  return !!userId
2    _id: newsId,
3    content,
4    defaultLanguage,
5    userId,
6    startsAt,
7    endsAt,
8    objectType,
9    objectId,
10    onlyDisplayOn
11}) => {
12  // Returns the details of the inserted news.


freedombase:flashnews-create Create a new flash news

  • @param content {Object} An object with the different locales should have format like this: { en: 'First news', cs: 'První novinka' } or instead of strings can include object with your default structure for the given language.
  • @param defaultLanguage {String} Default language of the news. This language will be used when the requested language is not available.
  • @param startsAt {Date} The starting date when the news should be displayed, by default it is the creation date.
  • @param endsAt {Date} Add a date when the news should stop being displayed, undefined by default.
  • @param objectType {String} APP_NEWS by default, but you can set here your own and in combination with objectId you can for example create custom news feed for groups.
  • @param objectId {String} Use in combination with objectType to specify a specific object under which to display the news.
  • @param onlyDisplayOn {String[]} Only display content to languages specified in this array. If the language does not match any in this array it will not show the news.



Gets current flash news for the site

  • @param limit {Number} Limit for the return, defaults to 3
  • @param language {String} Requested language of the news, defaults to en

@returns {Mongo.Cursor}


Gets current flash news for the given object

  • @param objectType {String}
  • @param objectId {String}
  • @param limit {Number} Limit for the return, defaults to 5
  • @param language {String} Requested language of the news, defaults to en

@returns {Mongo.Cursor}

FlashNews methods

Once you retrieve the news, you can call the following methods on the document.


Takes in the language you want to display the news in and returns the content given all the constraints set to it. If the language you have requested is not available then it will use the default language, unless you have set onlyDisplayOn.

1// subscription freedombase:flashnews-getMain
2const userLanguage = 'en'
3const news = FlashNewsCollection.find().fetch()
4const newsList = => {
5  return item.getContent(userLanguage)


Lists all the available languages for the current news based on the keys in content.

Contributors ✨

Thanks go to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!