ubervu / mozaic Goto Github PK
View Code? Open in Web Editor NEWJS Framework for building SPA
Home Page: http://ubervu.github.com/mozaic/
JS Framework for building SPA
Home Page: http://ubervu.github.com/mozaic/
Our SPA is using both require.js and Coffeescript. Right now, code is
fetched on-demand from the server as we need it, and is fetched
directly as Coffeescript. We want to change this in two ways:
- have a global switch which allows us to either a) fetch
Coffeescript or b) fetch JS. This global switch should somehow impact
the require.js Coffeescript loader, which should point to the default
loader when the global switch is enabled. Otherwise, it would compile
the Coffeescript code on the fly, as usual (in order to make it easy
for us to develop)
- have a packaging script which, based on a configuration file, takes
the existing Coffeescript files, compiles them into JS, minifies them,
bundles them together and archives them (into .jgz). Make sure that
the require.js behavior remains correct: whenever you request a file
from a given bundle B, the whole bundle should be fetched from the
server
You will be able to see the improvements by serving the TODO list app
with a web server with a single worker (such as Django's manage.py
runserver, or such as gunicorn with a single worker)
If we need to provide a blank state for a list of items, the default state management mechanism from widget.coffee doesn't play well with this: it calls changeState if old state differs from the new state or new state is available.
Therefore, when modifying an individual widget shown in the list, the whole list will be re-rendered instead of the individual item being re-rendered.
We already have it, only it's not in this repo yet.
Give an object:
releases =
browsers:
Chrome:
2010: 2
2011: 5
Firefox:
2010: 2
2011: 5
Utils.expandPath('browsers/*', releases)
method should return:
[ 'browsers/Chrome', 'browsers/Firefox']
add tests for channels_utils.coffee. Understand what the methods are doing and think of cases that could cause problems.
Add a base class for widgets that only work in modal dialogs, so that we can easily reuse (and eventually fix) all hacks involved with the modal window.
Try to figure out what the code does, and think of ways to test it.
add new tests for raw_data to check if its methods and behavior is OK.
When you want to render something initially (usually in the widget initial state) without sending the /new_widget_rendered signal to loading_animation, you should be able to silence this signal.
We are triggering an invalidate
each time before fetch.
https://github.com/uberVU/mozaic/blob/master/core/datasource/channel/read.coffee#L126-L131
receiving_channel.url = Utils.render_url(conf.url, params, [], conf.fetch_through_POST)
# Trigger a custom invalidate event before fetching the
# collection from the server (invalidate gets triggered
# every time a request is made to the server). The format
# of the event is: model, collection
receiving_channel.trigger('invalidate', null, receiving_channel)
receiving_channel.fetch(fetch_params)
And this is good because we can tell when a widget enter the loading
state:
previousStates = _.clone(@loadingStates)
for event, i in params
if event.type == 'no_data'
@loadingStates[i] = 'empty'
if event.type == 'invalidate'
@loadingStates[i] = 'loading'
if event.type in ['sync', 'change', 'reset', 'add', 'destroy']
# Check to see if the data on this specific channel is empty
if @isChannelDataEmpty(event, @loading_channels[i])
@loadingStates[i] = 'empty'
else
# Data has arrived on loading channels, the state should
# be available
@loadingStates[i] = 'available'
@transitionState(@loadingStates, previousStates, params)
But what happens when you try to add new items to a channel (paging scenario)? Before the fetch an invalidate
is triggered followed by several add
events (each one for the new items added to collection).
But when you receive only duplicates the add
event is not triggered anymore and the state remains in loading
indefinitely.
Modifications needed:
Our custom invalidate event wasn't thought that way - if we invalidate a model, the whole
collection should NOT be invalidated.
CC @skidding
Add support to the collection layer for widgets to subscribe to certain channels (such as the /social_profiles
channel) and only be called once.
This use case might be handy in cases where you want to do a certain action once, in case of an event, for example show a popup when the social profile list is retrieved.
datasource/channel/update.coffee:129
The idea is to encapsulated the waiting for channels to initialize (because of async requires of models and collections) inside the widget. It currently is in the widget starter.
This will also allow us to subscribe to newly created channels all inside a widget's initialize method. This is not currently possible.
This is a ballpark schema of the widget_starter > widget -> datasource flow
Also update last_fetch when updating channel (not only on fetch)
Why are we not merge 0.3.2(latest stable version) into master?
there are some existent tests in tests/pubsub_tests.coffee. Try to figure out what they do and add to the tests.
also, don't go into the "private" methods beginning with underscore, try to use the public and friendly ones.
Right now the expired collections are collected every 10 seconds by checkForUnusedCollections
method:
setInterval(@checkForUnusedCollections, @checkIntervalForUnusedCollections)
In order to make tests run faster I would like to be able to override checkIntervalForUnusedCollections
property. This would be achieved by replacing setInterval with setTimeout and schedule another callback at the end of checkForUnusedCollections
method.
@uberVU/mozaic-core-commiters
So far I updated it to 1.3.3 in order for the current code to work, but the current version is 1.4.0 and we should test it and update to it as soon as possible.
pipe = loader.get_module('pubsub')
pipe.publish('/new_widget_rendered', @params['widget_id'], @params['name'], this)
@rendered_signal_sent = true
These lines are called in renderLayout. Extract a method that would be needed when implementing custom triggers to /new_widget_rendered
event
Currently it only gets its default data from fixtures. Fix the 'Add' new item to the todo list.
new_widget_rendered
event is published only with reference to widget_id
and widget_name
Why not pass the widget instance as this
?
We need this in order to be able to track user actions more easily because of them reflecting in URL.
Pay attention to USE_PRECOMPILED_TEMPLATES
index.html shouldn't be changed by the average user ideally, so
<title>TodoVU</title>
since they come from the urls.js
configuration. And even if we want a fallback one, it should come from a config variablepage.hjs
, outside .controller-container
, and not in index.html. Especially stuff like <div class="ubervu-logo"></div>
https://github.com/uberVU/mozaic/blob/master/index.html#L21-22Makes development a pain because degugging is hard (chrome debugger won't jump into a function from a mixin).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.